Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Holzner's book

From: "steve.cpp" <steve.cpp@-----.--->
To: NULL
Date: 10/12/2009 4:00:00 PM
Hi,
I had a question about an example in Holzner's "XML: A Beginner's
Guide."  I have to learn XML quickly and picked up Holzner's book
based on some colleagues advice, as well as on some online reviews.  I
have minimal experience with XML, or with JavaScript, so apologies if
this is too easy.

He has the following code posted as an example:

<html>
   <head>
   	<title>
   		Retrieving data from an XML document.
   	</title>
   	<xml id="firstXML" src="hello.xml"></xml>
   	<script language="JavaScript">
   		function getData()
   		{
   			xmldoc = document.all("firstXML").XMLDocument;

   			nodeDoc = xmldoc.documentElement;
   			nodeGreeting = nodeDoc.firstChild;

   			outputMessage = "Greeting: " +
   				nodeGreeting.firstChild.nodeValue;
   			message.innerHTML=outputMessage;
   		}
   	</script>
   </head>

 <body>
    <center>
    	<h1>
    		Retrieving data from an XML document.
    	</h1>

    	<div id="message"></DIV>
    	<p>
    	<input type="button" value="Read the greeting."
    		onclick="getData()">
    </center>
  </body>
</html>

When I enter this same code and load the page using Firefox on a Linux
machine, I click the "Read the greeting button, nothing appears in the
web page, when "Greeting: Hello from XML" should appear.

When I open the error console and try the button again, it indicates
that xmldoc is undefined:

   			xmldoc = document.all("firstXML").XMLDocument;

I don't have any JavaScript books and the local Barnes & Noble didn't
have any in stock so I did some quick searching and found that I
should use "getElementById" instead.

I tried that and had the same results:

                         xmldoc = document.getElementById
("firstXML").XMLDocument;

I tried a few other things but again the same result.  I tried the
original code on a Windows box using IE and the code works as
described.

Is there a workaround to getting xmldoc defined correctly with Firefox?


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent