如何使用 C# 在 SCORM 中创建 imsmanifest.xml 文件

How to create imsmanifest.xml file in SCORM using c#

我想为我的 LMS 创建 SCORM 文件,但现在我在创建 imsmanifest.xml 文件时遇到了问题。

我想使用 C# 创建一个如下所示的 imsmanifest.xml

问题:任何人都可以提供示例代码或文档或任何可以帮助我的东西吗?

<?xml version="1.0" standalone="no" ?>
<manifest identifier = "title" version = "1.0"
    xmlns = "http://www.imsglobal.org/xsd/imscp_v1p1"
    xmlns:adlcp = "http://www.adlnet.org/xsd/adlcp_v1p3"
    xmlns:adlseq = "http://www.adlnet.org/xsd/adlseq_v1p3"
    xmlns:adlnav = "http://www.adlnet.org/xsd/adlnav_v1p3"
    xmlns:imsss = "http://www.imsglobal.org/xsd/imsss"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation = "http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1.xsd 
        http://www.adlnet.org/xsd/adlcp_v1p3 adlcp_v1p3.xsd
        http://www.adlnet.org/xsd/adlseq_v1p3 adlseq_v1p3.xsd
        http://www.adlnet.org/xsd/adlnav_v1p3 adlnav_v1p3.xsd
        http://www.imsglobal.org/xsd/imsss imsss_v1p0.xsd"
>
    <metadata>
        <schema>ADL SCORM</schema>
        <schemaversion>2004 4th Edition</schemaversion>
    </metadata>
    <organizations>
        <organization>
            <title>Something</title>
            <item identifier="EXAMPLE-SCO" identifierref="SCO-RESOURCE">
                <title>Something</title>   
            </item>
        </organization>
    </organizations>
    <resources>
        <resource identifier="SCO-RESOURCE" adlcp:scormType="sco" 
         type="webcontent" href="index.html">
            <file href="\css\bootstrap.css" />
            <file ... />
            <file ... />
        </resource>
    </resources>
</manifest>

代码如下所示

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;


namespace ConsoleApplication75
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {

            manifestType manifest = new manifestType()
            {
                metadata = new metadataType()
                {
                    schema = "ADL SCORM",
                    schemaversion = "2004 4th Edition"
                },
                organizations = new organizationsType()
                {
                    organization = new organizationType[] {
                           new organizationType() {
                              title = "Something",
                              item = new itemType[] { 
                                 new  itemType() {
                                    identifier = "EXAMPLE-SCO",
                                    identifierref = "SCO-RESOURCE",
                                    title = "Something"
                                 }
                              }
                          }
                    }
                },
                resources = new resourcesType() {
                    resource = new resourceType[] {
                        new resourceType() {
                           identifier = "SCO-RESOURCE",
                           type = "webcontent",
                           href = "index.html",
                           file = new fileType[] { 
                              new fileType { href = @"\css\bootstrap.css" }
                           }
                        }

                    }
                }
            };

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            XmlWriter writer = XmlWriter.Create(FILENAME, settings);
            XmlSerializer serializer = new XmlSerializer(typeof(manifestType));
            serializer.Serialize(writer, manifest);

        }

    }
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:4.0.30319.42000
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------



    // 
    // This source code was auto-generated by xsd, Version=4.0.30319.33440.
    // 


    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("dependency", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class dependencyType {

        private System.Xml.XmlElement[] anyField;

        private string identifierrefField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string identifierref {
            get {
                return this.identifierrefField;
            }
            set {
                this.identifierrefField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("file", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class fileType {

        private metadataType metadataField;

        private System.Xml.XmlElement[] anyField;

        private string hrefField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        public metadataType metadata {
            get {
                return this.metadataField;
            }
            set {
                this.metadataField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")]
        public string href {
            get {
                return this.hrefField;
            }
            set {
                this.hrefField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("metadata", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class metadataType {

        private string schemaField;

        private string schemaversionField;

        private System.Xml.XmlElement[] anyField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        public string schema {
            get {
                return this.schemaField;
            }
            set {
                this.schemaField = value;
            }
        }

        /// <remarks/>
        public string schemaversion {
            get {
                return this.schemaversionField;
            }
            set {
                this.schemaversionField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("item", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class itemType {

        private string titleField;

        private itemType[] itemField;

        private metadataType metadataField;

        private System.Xml.XmlElement[] anyField;

        private string identifierField;

        private string identifierrefField;

        private bool isvisibleField;

        private bool isvisibleFieldSpecified;

        private string parametersField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        public string title {
            get {
                return this.titleField;
            }
            set {
                this.titleField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("item")]
        public itemType[] item {
            get {
                return this.itemField;
            }
            set {
                this.itemField = value;
            }
        }

        /// <remarks/>
        public metadataType metadata {
            get {
                return this.metadataField;
            }
            set {
                this.metadataField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
        public string identifier {
            get {
                return this.identifierField;
            }
            set {
                this.identifierField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string identifierref {
            get {
                return this.identifierrefField;
            }
            set {
                this.identifierrefField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public bool isvisible {
            get {
                return this.isvisibleField;
            }
            set {
                this.isvisibleField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public bool isvisibleSpecified {
            get {
                return this.isvisibleFieldSpecified;
            }
            set {
                this.isvisibleFieldSpecified = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string parameters {
            get {
                return this.parametersField;
            }
            set {
                this.parametersField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("manifest", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class manifestType {

        private metadataType metadataField;

        private organizationsType organizationsField;

        private resourcesType resourcesField;

        private manifestType[] manifestField;

        private System.Xml.XmlElement[] anyField;

        private string identifierField;

        private string versionField;

        private string baseField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        public metadataType metadata {
            get {
                return this.metadataField;
            }
            set {
                this.metadataField = value;
            }
        }

        /// <remarks/>
        public organizationsType organizations {
            get {
                return this.organizationsField;
            }
            set {
                this.organizationsField = value;
            }
        }

        /// <remarks/>
        public resourcesType resources {
            get {
                return this.resourcesField;
            }
            set {
                this.resourcesField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("manifest")]
        public manifestType[] manifest {
            get {
                return this.manifestField;
            }
            set {
                this.manifestField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
        public string identifier {
            get {
                return this.identifierField;
            }
            set {
                this.identifierField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string version {
            get {
                return this.versionField;
            }
            set {
                this.versionField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace="http://www.w3.org/XML/1998/namespace")]
        public string @base {
            get {
                return this.baseField;
            }
            set {
                this.baseField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("organizations", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class organizationsType {

        private organizationType[] organizationField;

        private System.Xml.XmlElement[] anyField;

        private string defaultField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("organization")]
        public organizationType[] organization {
            get {
                return this.organizationField;
            }
            set {
                this.organizationField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(DataType="IDREF")]
        public string @default {
            get {
                return this.defaultField;
            }
            set {
                this.defaultField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("organization", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class organizationType {

        private string titleField;

        private itemType[] itemField;

        private metadataType metadataField;

        private System.Xml.XmlElement[] anyField;

        private string identifierField;

        private string structureField;

        private System.Xml.XmlAttribute[] anyAttrField;

        public organizationType() {
            this.structureField = "hierarchical";
        }

        /// <remarks/>
        public string title {
            get {
                return this.titleField;
            }
            set {
                this.titleField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("item")]
        public itemType[] item {
            get {
                return this.itemField;
            }
            set {
                this.itemField = value;
            }
        }

        /// <remarks/>
        public metadataType metadata {
            get {
                return this.metadataField;
            }
            set {
                this.metadataField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
        public string identifier {
            get {
                return this.identifierField;
            }
            set {
                this.identifierField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        [System.ComponentModel.DefaultValueAttribute("hierarchical")]
        public string structure {
            get {
                return this.structureField;
            }
            set {
                this.structureField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("resources", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class resourcesType {

        private resourceType[] resourceField;

        private System.Xml.XmlElement[] anyField;

        private string baseField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("resource")]
        public resourceType[] resource {
            get {
                return this.resourceField;
            }
            set {
                this.resourceField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace="http://www.w3.org/XML/1998/namespace")]
        public string @base {
            get {
                return this.baseField;
            }
            set {
                this.baseField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.imsglobal.org/xsd/imscp_v1p1")]
    [System.Xml.Serialization.XmlRootAttribute("resource", Namespace="http://www.imsglobal.org/xsd/imscp_v1p1", IsNullable=false)]
    public partial class resourceType {

        private metadataType metadataField;

        private fileType[] fileField;

        private dependencyType[] dependencyField;

        private System.Xml.XmlElement[] anyField;

        private string identifierField;

        private string typeField;

        private string baseField;

        private string hrefField;

        private System.Xml.XmlAttribute[] anyAttrField;

        /// <remarks/>
        public metadataType metadata {
            get {
                return this.metadataField;
            }
            set {
                this.metadataField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("file")]
        public fileType[] file {
            get {
                return this.fileField;
            }
            set {
                this.fileField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("dependency")]
        public dependencyType[] dependency {
            get {
                return this.dependencyField;
            }
            set {
                this.dependencyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyElementAttribute()]
        public System.Xml.XmlElement[] Any {
            get {
                return this.anyField;
            }
            set {
                this.anyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
        public string identifier {
            get {
                return this.identifierField;
            }
            set {
                this.identifierField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string type {
            get {
                return this.typeField;
            }
            set {
                this.typeField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace="http://www.w3.org/XML/1998/namespace")]
        public string @base {
            get {
                return this.baseField;
            }
            set {
                this.baseField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")]
        public string href {
            get {
                return this.hrefField;
            }
            set {
                this.hrefField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Xml.XmlAttribute[] AnyAttr {
            get {
                return this.anyAttrField;
            }
            set {
                this.anyAttrField = value;
            }
        }
    }




}