javascript - xml2js filter objects based on element tags -
<xml> <title name="foo"> </title> <clip id="0"> <clip id="1"> </clip> <transition> <sub> <clip id="2"> </clip> </sub> <clip id="5"> </clip> </transition> </clip> </xml>
hi, i'm using xml2js parse xml above (simplified). want filter objects refer nodes 'clip' element tag. how do without knowing structure of xml per parsing session except root node one?
<xml></xml>
update: answer own question: used jsonpath node module , inside xml2js parser listener:
var jp = require('jsonpath'); var nodes = jp.query(parsedxml.xml, "$..clip"); (var = 0; < nodes.length; i++) { nodes[i].foreach(function (entry) { // entry.$ object(s) i'm looking for... }); }
Comments
Post a Comment