Generate XML with multiple namespaces using XDocument

前端 未结 2 1823
礼貌的吻别
礼貌的吻别 2021-01-14 13:47

I have XML like this:



        
2条回答
  •  青春惊慌失措
    2021-01-14 14:45

    you can add the namespace like

     XElement root = new XElement("{http://www.adventure-works.com}Root",
        new XAttribute(XNamespace.Xmlns + "aw", "http://www.adventure-works.com"),
        new XElement("{http://www.adventure-works.com}Child", "child content")
    );
    

    This example produces the following output:

        
      child content
    
    

提交回复
热议问题