wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Problem getting Javascript to display XML data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem getting Javascript to display XML data" Watch "Problem getting Javascript to display XML data" New topic
Author

Problem getting Javascript to display XML data

Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI,
XML beginner problem:
I visited www.xml101.com as suggested in another thread and I was doing a tutorial.
When I tried to get javascript to display data on my own computer by copying an XML file and the HTML file from the site to a single folder on my computer they wouldn't work. The HTML file doesn't seem to get the data.
I have PWS activated and IE 5.5.
What else must I do to get this working?

Thanks in advance for any help.
Terry


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi,
I got another example to work by using a different way of embedding the XML I found it a this site:
www.inquiry.com/techtips/dhtml_pro/10min/10min0501/td051501-1.asp

I still don't know why the other way works on their site and not on my PC though

[This message has been edited by Terence Doyle (edited August 07, 2001).]
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Terence
Can you post the code so we can take a look at it. I'n new to xml myself but, fairly proficient with javascript and html.

Dave


Dave
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Sure.
Heres the xml document called 'note.xml' :

And here's the html document:



[This message has been edited by Terence Doyle (edited August 07, 2001).]
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
I tried to run your code. Its working fine. I can't think of any reason why isn't it working on your machine?


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Thanks.
I'll have to do some other tests to see what's up.
Terry
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
In case you are still not able to solve your problem try accessing the XML elements by name. Addressing elements by number is not the preferred way to extract XML elements from an XML document. Using names is a better way.
Try to replace the following JavaScript lines that reads XML data from an XML document and writes the XML data into (waiting) HTML elements.

your code
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
Make sure that you notice that the text element of a node is the child node of the element.
To extract the text (AFriend) from an element like this: <from>AFriend</from>, you must address the child node
like this: getElementsByTagName("from").item(0).text,
and not like this: getElementsByTagName("from").text
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI,
Thanks for the idea Parmeet but that doesn't work either. I get an error message
"Line 7: An Object is required"
It's as if the span objects weren't defined.

Terry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem getting Javascript to display XML data
 
Similar Threads
XML
XML Tutorials
Document type
Can we pass parameters from a Javascript function to an XSL file
XML and Java