faqts : Computers : Programming : Languages : 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?

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

Entry

How do I use the method localName?
How do I use the method localName?

Apr 11th, 2005 01:56
Martin Honnen,


The method localName takes no argument and returns the local name part
if the XML object has a name.
Note that text nodes and comment nodes do not have a name thus for these
kind of XML objects null is returned.
Here are some examples:
  var god = <god>Kibo</god>;
  alert(god.localName()); // shows 'god'
  var p = <xhtml:p xmlns:xhtml="http://www.w3.org/1999/xhtml">Kibology
for all.</xhtml:p>;
  alert(p.localName()); // shows 'p'
  var xlink = new Namespace('http://www.w3.org/1999/xlink');
  var attributeNode = <home xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple" />.@xlink::type;
  alert(attributeNode.localName()); // shows 'type'
  XML.ignoreProcessingInstructions = false;
  var pi = <?process Kibology="on"?>;
  alert(pi.localName()); // shows 'process'
  var textNode = new XML('Kibology for all.');
  alert(textNode.localName()); // shows 'null'
  XML.ignoreComments = false;
  var comment = <!-- All for Kibology. -->;
  alert(comment.localName()); // shows 'null'