Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 11th, 2005, 03:24 PM
Registered User
Join Date: Oct 2005
Location: Fife, WA, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML Retrieval Help

Hi I'm working on using an example out of the book on retrieving XML and I'm starting to get really turned around in making it work for Mozilla. I am also wondering if I could use the oXmlDom.getElementByTagName() method but for some reason when I do that I get an error. It tells me that oXmlDom has no properties. I'm new to all the XML and javascript world so I'm not sure what I'm doing wrong. But here is a current code example of what I'm working on:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <title>Cross-Browser XML DOM Example</title>
        <script type="text/javascript" src="scripts/detect.js"></script>

        <script type="text/javascript" src="scripts/xmldom.js"></script>

          <style type="text/css">
            body {
                font-family: "Trebuchet MS", Arial, Helvetica;
                font-size: 10pt;
            .msg {
                width: 500px;
                font-family:"Trebuchet MS", Arial, Helvetica;
                border: 3px solid #ccc;
                padding: 10px;
            html>body .msg {
                width: 490;
            .line {
                border-bottom: 2px solid grey;
                width: 600px;
            .codeMsg {
                font-style: italic;
                font-weight: bold;
                color: #CC3366;
            This example loads a valid XML file and displays an alert showing us what 
            the root element is and how many child nodes there are.
        <script type="text/javascript">
            var oXmlDom = new XmlDom();
            oXmlDom.onreadystatechange = function () {
                if (oXmlDom.readyState == 4) {

                    if (oXmlDom.parseError != 0) {
                        var oError = oXmlDom.parseError;
                        alert("An error occurred:\nError Code: "
                        + oError.errorCode + "\n"
                        + "Line: " + oError.line + "\n"
                        + "Line Pos: " + oError.linepos + "\n"
                        + "Reason: " + oError.reason);


            // Load the xml
            var    file    =    "xml/e_learning.xml";
        <h3>Message that XML document has loaded</h3>
        <div class="msg">
            <script type="text/javascript" language="javascript">
                    oXmlDom.onload    =    document.write('The XML file: <span class=\"codeMsg\">'+file+'</span> has been loaded');

        <h3>We are testing the existance of: <span class="codeMsg">oXmlDom</span></h3>
        <div class="msg">
            <div class="codeMsg">
                <script type="text/javascript" language="javascript">
            <br />
            <script type="text/javascript" language="javascript">

                var oEvaluator = new XPathEvaluator();
            var oResult = oEvaluator.evaluate("welcome/title", oXmlDom.documentElement, null, XPathResult.STRING_TYPE, null);

My xml document is (e_learning.xml) in the folder "xml":
<?xml version="1.0" encoding="iso-8859-1"?>
        <title>C17 FEDS</title>
I'm trying to get to the title...so how do I do this?

When running this code i get this error
Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMXPathEvaluator.evaluate]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: file:///Macintosh%20HD/Documents/Business/Intrepid/Projects/excel_to_xml/CrossBrowserXmlDomExample2.html :: <TOP_LEVEL> :: line 82"  data: no]
What am I doing wrong?

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date retrieval Neal Excel VBA 1 February 1st, 2007 06:43 AM
For XML data retrieval fancorning4 SQL Server 2000 2 May 18th, 2006 10:33 AM
DropDownList selectedindex retrieval poison_king ASP.NET 1.0 and 1.1 Professional 5 September 21st, 2004 09:44 AM
Binary storage and retrieval acm54 SQL Server ASP 0 January 26th, 2004 10:30 PM
Data retrieval using MySQL rajanikrishna Beginning PHP 2 November 12th, 2003 11:38 PM

All times are GMT -4. The time now is 03:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.