xml节点
要求完成
为什么 我写出来是
<?xml version="1.0" encoding="GB2312"?>
<result updatecount="1" message="同步成功" status="0"/>
没有最后的<result> 求大神啊 我代码是
XmlDocument xmldoc = new XmlDocument();
XmlDeclaration xmldecl; xmldecl = xmldoc.CreateXmlDeclaration("1.0", "GB2312", null);
xmldoc.AppendChild(xmldecl);
XmlElement xmlelem;
xmlelem = xmldoc.CreateElement("", "result", "");
xmlelem.SetAttribute("status", "0");
xmlelem.SetAttribute("message", "同步成功");
xmlelem.SetAttribute("updatecount", "1");
xmldoc.AppendChild(xmlelem); XML 编码
[解决办法]
<result updatecount="1" message="同步成功" status="0"/>
<result updatecount="1" message="同步成功" status="0"></result>
一样的
[解决办法]
XmlDocument xmldoc = new XmlDocument();
XmlDeclaration xmldecl;
xmldecl = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", null);
xmldoc.AppendChild(xmldecl);
XmlElement xmlelem = xmldoc.CreateElement("", "result", "");
xmlelem.InnerText ="同步成功";
xmldoc.AppendChild(xmlelem);