Node to parse xml using xml2js

johnr

New Member
I am trying to parse and query for an element within an xml using xml2js. My xml string is as follows:\[code\]var xml = "<config><test>Hello</test><data>SomeData</data></config>";\[/code\]What I want is to extract the value in and assign it to \[code\]var extractedData\[/code\]Here's what I have so far:\[code\]var parser = new xml2js.Parser();parser.parseString(xml, function(err,result){ //Extract the value from the data element extractedData = http://stackoverflow.com/questions/10904448/result['data'];}\[/code\]This does not work. Can somebody point out how I might be able to grab the values from my xml?ThanksThis doesn't seem to be working. Can somebody tell me what might be the issue here?
 
Back
Top