如何设置" " C#中的XML文档

时间:2016-12-20 08:39:46

标签: c# xml escaping xmldocument innertext

我想将"
"设置为Xml文件。但我的下方和弦无意中更改了\ n。 我可以在XML文件中设置"
"吗? 请教我。

        foreach (XmlNode xnode in secondNode)
        {
            if (xnode.NodeType == XmlNodeType.Element && xnode.Name == "element")
            {
                string line1 = model.Second.CommentList[j].Line1;
                string line2 = model.Second.CommentList[j].Line2;

                if (string.IsNullOrEmpty(line2))
                {
                    xnode.InnerXml = line1;
                }
                else
                {
                    xnode.InnerXml = line1 + "
" + line2;
                }
                j++;
            }
        }
        var outputStream = new MemoryStream();
        outputStream.Position = 0;
        using (XmlWriter xw = XmlWriter.Create(outputStream))
        {
            doc.WriteTo(xw);
        }
        outputStream.Flush();
        outputStream.Position = 0;

0 个答案:

没有答案