使用c#中的命名空间前缀生成XML

时间:2016-11-29 10:57:01

标签: c# .net xml

我需要为xml

下面的代码提供什么修改
<?xml version="1.0"?>
 <CheckInLoad xmlns="http://fake.com/schemas/insert"         xmlns:cmn="http://fake.com/schemas/common" >
<Input>
  <cmn:EmpId>100</cmn:EmpId>
</Input>
</CheckInLoad>

这是类定义

  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://fake.com/schemas/Insert")]
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://fake.com/schemas/Insert", IsNullable = false)]
    public partial class CheckInLoad
    {
        private CheckInLoadHeader headerField;
        public CheckInLoadHeader Header
        {
            get
            {
                return this.headerField;
            }
            set
            {
                this.headerField = value;
            }
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://fake.com/schemas/Insert")]
    public partial class CheckInLoadHeader
    {

        private string empIdField;


        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://fake.com/schemas/common")]
        public string EmpId
        {
            get
            {
                return this.empIdField;
            }
            set
            {
                this.empIdField = value;
            }
        }

    }

请告诉我在课堂上需要做些什么样的改变。请注意,我使用下面的代码将对象转换为xml

     var stringwriter = new System.IO.StringWriter();
        var serializer = new XmlSerializer(load.GetType());
        serializer.Serialize(stringwriter, load);
        return stringwriter.ToString();

1 个答案:

答案 0 :(得分:0)

SELECT ?item ?title ?publicationdate
WHERE { 
    ?item wdt:P31 wd:Q11424 ;
        rdfs:label ?title ;
        wdt:P577 ?publicationdate ;
    filter ( lang(?title) = "en" )
}
ORDER BY ?movieid
LIMIT 10

试试这个。