c# - Linq to Xml: error on saving a document twice -


i have following xml:

<?xml version="1.0" encoding="utf-16" standalone="yes"?> <property_set_list xmlns="mynamespace">     <property_set symbol_id="config">        </property_set> </property_set_list> 

i want open it, add property close , edit added property , save again:

var xws = new xmlwritersettings { indent = true, indentchars = tab };  using (var reader = readercreator()) using (var output = outputcreator()) using (var xmlwriter = xmlwriter.create(output, xws)) {     xdoc = xelement.load(reader, loadoptions.none);     namespace = "mynamespace";      // append node        appendtonode("config", "", main_lobby_list_ctrl_local_tables_color,                        318, 8);      xdoc.save(xmlwriter);      // edit added node     setcolors();      // error here     xdoc.save(xmlwriter); 

}

the property added. saved successfully. edited successfully. receive following error on second save :

"token startdocument in state end document result in invalid xml document." 

what can here ? suggestions welcome.

you have create xmlwriter. there no way reset , start writing again begining of underlying stream.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -