Faqts : Business : Programming : Shopping For You : JavaScript : XML : E4X (ECMAScript for XML) : XML objects

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 1 people (100%) answered Yes
Recently 1 of 1 people (100%) answered Yes

Entry

How do I use the method nodeKind?
How do I use the method nodeKind?

Apr 11th, 2005 04:13
Shopping Snooper, Casino Vendor Directory, 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'