Removing preprocessing instructions from an XML in c#

后端 未结 2 839
暖寄归人
暖寄归人 2021-01-26 04:33

How can i remove preprocessing instructions from an XML in a greener way? suppose that I have this xml in a string variable (which is a property of a class),I wante

2条回答
  •  -上瘾入骨i
    2021-01-26 05:22

    Try the code below. It will load the text to XmlDocument object first

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(xmlAsText);
    

    Then you can get the OutherXml using below:

    xmlDoc.DocumentElement.OuterXml;
    

提交回复
热议问题