Please, someone tell me there is a built in way to do this. But in the interim, since I don’t know of another way, if you’re looking for a child of a given node (by name), you can do it something like this.
// Used to store the matched node, if found. var _jsMatchedNode; function jsFindChildByName(pvNodeName, pvParent) { if (pvParent.nodeName.toLowerCase() == pvNodeName.toLowerCase()) { _jsMatchedNode = pvParent; return; } if (!pvParent.childNodes) return; if (pvParent.childNodes.length == 0) return; var nodeList = pvParent.childNodes; for(var x=0;x<nodeList.length;x++) { jsFindChildByName(pvNodeName, nodeList[x]); } }
Of course if you use this repeatedly it would behoove you to reset the _jsMatchedNode variable before each use.