Search tutorials
Here are the goods:
function selectSingleNode(node, name) {
for (i = 0; i < node.childNodes.length; i++) {
if (node.childNodes[i].nodeName == name) {
return node.childNodes[i];
}
}
}
function selectSingleNodeValue(node, name) {
var selNode = selectSingleNode(node, name);
return selNode.firstChild.nodeValue;
}
function selectSingleNodeAttribute(node, name, attrib) {
var selNode = selectSingleNode(node, name);
return selNode.attributes[attrib];
}
Usage is simple:
//Returns the child node you're looking for selectSingleNode(parentNode, "Node To Find"); //Returns the value for the node you're looking for selectSingleNodeValue(parentNode, "Node to Find"); //Returns the attribute in the node you're looking for selectSingleNodeAttribute(parentNode, "Node to Find", "Attribute To Find");
Use them as an Include file whenever you're working with XML. It makes working with XML a little easier.
| » Level Basic |
|
Added: 2003-04-07 Rating: 3 Votes: 12 |
| » Author |
| Enjoy! |
| » Download |
| Download the files used in this tutorial. |
| Download (0 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!