have xml traverse code in vbscript, need javascript alternative

M

mr_burns

Hi,

I have the following code:

set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("xml/categories.xml")

z = '<p>'
for each x in xmlDoc.documentElement.childNodes
z = z + x.text + '<br>'
next
z = z + '</p>'

document.getElementById('title').innerHTML = z


the way my page is set up is that i have linked a external javascript
file (site.js) that has laods of functions that the site relies on
using the following code:

<script src="site.js" content="text/javascript;
charset=iso-8859-1"></script>

i need code that does the same as the above but javascript instead of
vbscript. i could create an alternative file that contains vbscript
like so i guess:

<script src="site_vbscript.js" content="text/vbscript;
charset=iso-8859-1"></script>

.... but it would be better if i could get javascript as i could store
all functions in the one file.

also, i need to obtain not only the text inside the node (x.text) but
also one of the nodes attributes (id ... x.get_attribute('id') or
something like that).

any help? cheers

burnsy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top