How to set "
" to XML Document in C#

437 views Asked by At

I want to set "
" to Xml file.But my below chord Unintentionally changed \n. Can I set "
" in XML File? please teach me.

        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

There are 0 answers