http://james.newtonking.com/projects/json/help/
为什么我使用“DeserializeXmlNode”并将我的JSON转换为XML文档 然后将我的XML文档转换为像这样的字符串
string strXML = "";
StringWriter writer = new StringWriter();
xmlDoc.Save(writer);
strXML = writer.ToString();
它包括
<?xml version="1.0" encoding="utf-16"?>
我没有添加此内容,如何将其删除?
答案 0 :(得分:4)
答案 1 :(得分:3)
将XmlWriter与StringBuilder一起使用,而不是使用StringWriter
var strXML = "";
var writer = new StringBuilder();
var settings = new System.Xml.XmlWriterSettings() { OmitXmlDeclaration = true};
var xmlWriter = System.Xml.XmlWriter.Create(strXML, settings);
xmlDoc.Save(xmlWriter);
strXML = writer.ToString();