xmltextwriter - xml white space issue using c# -
i creating xml file using below code problem when there spaces in sentence or content code converting single space how handle
using system; using system.io; using system.xml; public class sample { public static void main() { // create writer. xmltextwriter author = null; author = new xmltextwriter("c:\\ws.html", null); // write element (this 1 root). writer.writestartelement("p"); // write xml:space attribute. writer.writeattributestring("xml", "space", null, "preserve"); // verify xml:space set properly. if (writer.xmlspace == xmlspace.preserve) console.writeline("xmlspace correct!"); // write out html elements. insert white space // between 'something' , 'big' writer.writestring("something spacess in line not coming in xml want spaces"); writer.writewhitespace(" "); writer.writeelementstring("b", "b"); writer.writestring("ig"); // write root end element. writer.writeendelement(); // write xml file , close writer. writer.close(); } }
have tried writer.writecdata()
? surround <![cdata[...]]>
block may preserve spaces (haven't tried myself, couldn't say).
obviously, not great if don't want info block.
xml xmltextwriter
No comments:
Post a Comment