Entry
How do I use the method nodeKind?
How do I use the method nodeKind?
Apr 11th, 2005 04:13
Martin Honnen,
The method nodeKind takes no argument and returns a string denoting the
kind of node this XML object represents. The possible values are
'element', 'attribute', 'text', 'comment', and 'processing-instruction'.
Here are some examples:
XML.ignoreComments = false;
XML.ignoreProcessingInstructions = false;
var gods = <gods type="usenet">
<?process Kibology="on"?>
<!-- usenet GOD -->
<god>Kibo</god>
<!-- counterpart -->
<god>Xibo</god>
</gods>;
alert(gods.nodeKind()); // shows 'element'
alert(gods.@type.nodeKind()); // shows 'attribute'
alert(gods.*[0].nodeKind()); // shows 'processing-instruction'
alert(gods.god[0].*[0].nodeKind()); // shows 'text'
alert(gods.*[1].nodeKind()); // shows 'comment'