Reputation: 542
i am struck in problem of writing to an XML file. I know how to read an xml file. Let me explain it clearly. I have to read the value from an xml file and pass it to a label or listbox and then write the value to another xml file. I did the first part of reading and i am struck in writing. I have gone through several queries in stackoverflow. But its not working for me. Help me out Here is the code which i used for writing
var v = new XMLWriter();
v.writeStartDocument(true);
v.writeElementString('option','Hello World');
v.writeAttributeString('foo','bar');
v.writeEndDocument();
console.log( v.flush() );
Upvotes: 1
Views: 11600
Reputation: 18016
From here
function test(){
var v = new XMLWriter();
v.writeStartDocument(true);
v.writeElementString('test','Hello World');
v.writeAttributeString('foo','bar');
v.writeEndDocument();
console.log( v.flush() );
}
that will produce
<?xml version="1.0" encoding="ISO-8859-1" standalone="true" ?>
<test foo="bar">Hello World</test>
Upvotes: 3