locked
documentElement.selectSingleNode RRS feed

  • Question

  • User698141338 posted

    Hi all,

    IE Supports .documentElement.selectSingleNode("something") to get node value ...

    Is  ".documentElement.selectSingleNode("something")" is supported by the browsers like FF,CHrome,Safari  to get the selected node value

    dont want to use "XPathEvaluater()"

    if yes the please explain give some sample code..

    Thank You,....

    Thursday, August 29, 2013 9:12 AM

Answers

  • User-933407369 posted

    hi Siddu,

    According to your description, I understand you want to “.documentElement.selectSingleNode("something")" is supported by the browsers like FF,CHrome,Safari  to get the selected node value.

    I would suggest you to try the following methods: 

    Path support
    
    xmldoc.setProperty("SelectionLanguage", "XPath");
    
          var books = xmldoc.documentElement.selectNodes("//book");
    
          var secondBook = xmldoc.documentElement.selectSingleNode("//book[2]");
    
    var secondAuthor = secondBook.selectSingleNode("author[2]");
    
    Namespace support
    
       <books xmlns:wrox="http://www.wrox.com/" xmlns="http://www.amazon.com/">
    
           <wrox:book>Professional JavaScript</book>
    
       </books>
    
         xmldoc.setProperty("SelectionNamespaces",
    
        "xmlns:wrox='http://www.wrox.com/' xmlns='http://www.amazon.com/'");
    
    var book = xmldoc.documentElement.selectSingleNode("wrox:book");

    Please read the reference below for more information:

    http://www.nczonline.net/blog/2009/04/04/xpath-in-javascript-part-3/

    I hope it helps you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 30, 2013 5:15 AM