Hello,
I will try to describe the best I can what I am trying to accomplish. I am parsing out this xml file into a javascript file. I have everything working and I am at my last step where I need to place the menu in the right spot. I will show you the important bits of code + xml to describe the problem.
I am currently returning the nodeName but what I want to do is return the attribute id="id01". I tried using the paremeter getAttribute("id") but my script keeps giving me an error. Is it possible to return the id="id01" with out looking up thje parentNode twice? Any help would be greatly appreciated, I have been trying to figure this out for way to long. Thank you in advanced!
I will try to describe the best I can what I am trying to accomplish. I am parsing out this xml file into a javascript file. I have everything working and I am at my last step where I need to place the menu in the right spot. I will show you the important bits of code + xml to describe the problem.
I am currently returning the nodeName but what I want to do is return the attribute id="id01". I tried using the paremeter getAttribute("id") but my script keeps giving me an error. Is it possible to return the id="id01" with out looking up thje parentNode twice? Any help would be greatly appreciated, I have been trying to figure this out for way to long. Thank you in advanced!
Code:
mycode.vbs
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load("menu.xml")
set n = xmlDoc.getElementsByTagName("title")(5)
msgbox(n.text)
set p_node = n.parentNode
msgbox(p_node.nodeName) //returns item
set pp_node = p_node.parentNode
msgbox(pp_node.nodeName) //returns item2
Code:
menu.xml
<?xml version="1.0" encoding="UTF-8"?>
<test>
<title>My menu</title>
<item2 id="id01" isvisible="true">
<title>Questions</title>
<item1 id="id02" isvisible="true">
<title>Sub menu of question</title>
<item id="id03" idref="idr01" isvisible="true">
<title>Question 1</title>
</item>
<item id="id04" idref="idr02" isvisible="true">
<title>Question 2</title>
</item>
</item1>
<item id="id05" idref="idr03" isvisible="true">
<title>Content 1</title>
</item>
<item id="id06" idref="idr04" isvisible="true">
<title>Content 2</title>
</item>
</item2>
</test>