How to add namespace prefix for IXmlSerializable type

后端 未结 3 2000
执念已碎
执念已碎 2021-01-17 11:29

I have a following class definition

[XmlRoot(ElementName = \"person\",Namespace = \"MyNamespace\")]
public class Perso         


        
3条回答
  •  执念已碎
    2021-01-17 11:44

    Try the following.

    public void WriteXml(XmlWriter writer)
    {
        writer.WriteAttributeString("xmlns", "my", null, "MyNamespace");
        writer.WriteElementString("firstName", FirstName);
        writer.WriteElementString("lastName", LastName);
    }
    

提交回复
热议问题