c# - How to add attribute and also elementString via XmlTextWriter? -
c# - How to add attribute and also elementString via XmlTextWriter? -
i using xmltextwriter
generate xml file. parts fine, encounter problem generate bellow part, need is:
<site istrue="false">http://www.example.com</site>
partly main code of mine:
... using system.xml; string filepath = application.startuppath + "\\myxml.xml"; xmltextwriter myxml = null; seek { myxml = new xmltextwriter(filepath, system.text.encoding.utf8); myxml.writestartdocument(); // // first myxml.writeelementstring("site","http://www.example.com"); // // sec // myxml.writestartelement("site") myxml.writeattributestring("istrue", "false"); } ...
then, first method seek , result is:
<site>http://www.example.com</site>
or if utilize sec seek ,then result become:
<site istrue="false"></site>
any method add together attribute , innertext? bellow:
<site istrue="false">http://www.example.com</site>
myxml.writestartelement("site"); myxml.writeattributestring("istrue", "false"); myxml.writestring("http://www.example.com");
c# xml xmltextwriter
Comments
Post a Comment