How to avoid encoding of special characters in xmlroot

柔情痞子 提交于 2019-12-02 08:03:24

I believe you are looking for the Xml Namespace functions

[Serializable, XmlRoot("BatchChanges, Namespace = "http://www.w3.org/XML/2008/xsdl-exx/ns1") ]
public class JTDChanges
{
    [XmlElement("OrgUnitChanges")]
    public List<OrgUnitStage> CustomerChanges = new List<OrgUnitStage>();
} 

Now before this really has a effect, you also need to tell your serializer to use this namespace

// Create a name space prefix
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("ns1", "ttp://www.w3.org/XML/2008/xsdl-exx/ns1");

// Create a serializer
System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(this.GetType());

// And pass the namespace along as param
ser.Serialize(writer, this, ns)

As for a test you could declare the following

 [XmlElement(ElementName = "point", Namespace = "http://www.w3.org/XML/2008/xsdl-exx/ns1")]

which would result in <ns1:point>(whatever the values were you declared it upon)</ns1:point>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!