Click to See Complete Forum and Search --> : Displaying XML in javascript
keepoffthegrass
02-09-2006, 04:08 AM
I have a ownerDocument object.
How do I grab the XML as a string thats held inside this?
Really appreciate any help on this
swtrans
02-09-2006, 04:17 AM
Not sure if this is what you are looking for. This example would display "Current $40" from the <a05 line.
<html>
<body>
<script type="text/javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("price.xml")
document.write
(xmlDoc.documentElement.childNodes.item(5).text)
</script>
</body>
</html>
XML File:
<note>
<filler>None</filler>
<a01brick>Current $0</a01brick>
<a02choir>Current $0</a02choir>
<a03mcnatt>Current $8</a03mcnatt>
<a04oakmont>Current $60</a04oakmont>
<a05robson>Current $40</a05robson>
<a06xmascd>Current $0</a06xmascd>
<a07shirt>Current $0</a07shirt>
<a08salsa>Current $0</a08salsa>
<a09bird>Current $0</a09bird>
<a10mug>Current $0</a10mug>
</note>
keepoffthegrass
02-09-2006, 04:19 AM
Many thanks for your help!
This is pretty much what I need, however I'd like to be able to display the whole XML document.
How would I do this?
swtrans
02-09-2006, 04:53 AM
I'm not sure, but somone here will know. Has to be some modification (or elimination) of this line I would think????
(xmlDoc.documentElement.childNodes.item(5).text)
swtrans
02-09-2006, 08:15 AM
I changed:
(xmlDoc.documentElement.childNodes.item(5).text)
to
(xmlDoc.documentElement.text)
It displays everything, but as a stream. You probably need it in a column. One of these guys will know how to do that.
I'm not sure, but this might only work using Internet Explorer. It is a question that needs to be asked.