What you're looking for is a way to go back from a data object into an XML string. This example script will pretty-print an XML stream as it's fed into the parser. You could probably modify it to fit your needs.
https://github.com/isaacs/sax-js/blob/master/examples/pretty-print.js On Wed, Oct 31, 2012 at 3:14 PM, Udayantha Warnasuriya <[email protected]> wrote: > Does anyone know how to modify a tag value of an XML file using NodeJS > > this is my XML file: > > <note> > <to>Tove</to> > <from>Jani</from> > <heading>Reminder</heading> > <body>Don't forget me this weekend!</body> > </note> > > I want to change the <node> to <n> > > I'm running nodeJS on windows. SO far I have following code; > > var parser = new xml2js.Parser(); > function xmltxt(response, postData){ > fs.readFile( './foo.xml', function(err, data) { > parser.parseString(data, function (err, result) { > console.dir(result.note.to[0]); > }); > }); > } > > This reads the node value but I need to modify the tag value. Please help. > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
