Hi all,
Please provide me solution how to parse xml using spidermonkey or jslibs . i tried small program but stuck at attribute value.....
/************* test.xml ************/
<note>
<to key='hello'>joseph</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
/*********** parse.js ***********/
var loadModule = host.loadModule;
loadModule('jsstd');
loadModule('jsio');
var buf;
var file = new File('../jslibs/test.xml');
if ( file.exist ) {
file.open( File.RDONLY );
buf = file.read(65535);
print(buf);
file.close();
}
var data = stringify(buf);
var xmlData = new XML(data);
print('\nattribute :'+xmlData.to+'\n');
this program prints xml file and prints value within tags ( <to></to> ) but i am unable to retrieve value of attribute ( key="hello" attribute of tag <to> )
how will i be able to do this...
regards
sachin