Parse XML Libxmljs (Node.js) -
i'm attempting parse xml string libxmljs (https://github.com/polotek/libxmljs). i'm having issues though. need apply logic i'm parsing , return based upon what's defined , isn't. because of don't see sax-style parser being valid option.
i'm willing @ other alternatives if can achieve i'm looking for. being able select elements domparser xmldoc.getelementsbyid('firstname')[0].childnodes[0].nodevalue
awesome...
libxmljs supports dom sax style parsing.
var xmldoc = libxmljs.parsexmlstring('<item><data id="firstname">your name</data></item>'); var xmldoc2 = libxmljs.parsexmlfile('mydata.xml');
the api custom , doesn't follow w3c/browser spec (it's on list). want use xpath query document content want.
xmldoc.find("//[@id='firstname']")[0].childnodes()[0].text()
notice childnodes , text function calls. take @ docs.
https://github.com/polotek/libxmljs/wiki/element
as far know, libxmljs , jsdom 2 libraries have decent dom implementations.
Comments
Post a Comment