Error :Objected Required while getting node value from the xml file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NawazAhmed
    New Member
    • Feb 2008
    • 36

    Error :Objected Required while getting node value from the xml file

    Hi,
    I am just trying to get the node value from the xml file "books.xml" .
    I am getting error: Object Required at line 12.
    What can be the solution for this???

    This is my script
    <HTML>
    <HEAD>
    </HEAD>
    <body>
    <script type="text/javascript">
    xmlDoc=new ActiveXObject(" Microsoft.XMLDO M");
    xmlDoc.async=fa lse;
    xmlDoc.load("bo oks.xml");
    x=xmlDoc.getEle mentsByTagName( "price")[0].childNodes[0];
    document.write( x.nodeValue);
    </script>
    </body>
    </HTML>
    *************** *************** *************** *************** ********
    and books.xml code is
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <bookstore>
    <book category="COOKI NG">
    <title lang="en">Every day Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
    </book>
    <book category="CHILD REN">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
    </book>
    </bookstore>
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    To be honest, I can not find fault with what you've posted.

    When executing this, it gives me 30.00

    Maybe the error is elsewhere in your code?

    Comment

    Working...