Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot retrieve the child node

Status
Not open for further replies.

kate1234

Programmer
Dec 19, 2005
2
US
<GROUP_1>
<GROUP_2>
<LX LX_VALUE = "1" />
<GROUP_3>
<AX AX_VALUE = "1" />
<GROUP_4>
<CL CL_VALUE = "CL1" />
<CK CK_VALUE = "CK1"/>
<GROUP_5>
<GROUP_6>
<SV SV_VALUE = "SV1" />
</GROUP_6>
<GROUP_6>
<SV SV_VALUE = "SV2" />
</GROUP_6>
</GROUP_5>
</GROUP_4>
<GROUP_4>
<CL CL_VALUE = "CL1" />
<CK CK_VALUE = "CK1"/>
<GROUP_5>
<GROUP_6>
<SV SV_VALUE = "SV1" />
</GROUP_6>
<GROUP_6>
<SV SV_VALUE = "SV2" />
</GROUP_6>
</GROUP_5>
</GROUP_4>
</GROUP_3>
</GROUP_2>
</GROUP_1>

I WANT TO RETRIEVE THE VALUE OF SV SEGMENT

I WROTE THE FOLLOWING CODE BUT IT DOESNT WORK IN VBSCRIPT



Set Dom = CreateObject("MSXML2.DomDocument")
Dom.async = false
Dom.LoadXml(self.BodyAsXml)

SET ID = DOM.SELECTNODES("/GROUP_1/GROUP_2")

FOR EACH X IN ID.SELECTNODES("GROUP_3/GROUP_4")
set y = x.selectSINGLENODE("CL")
FOR EACH Z IN X.SELECTNODES("GROUP_5/GROUP_6">
SET SV = Z.SELECTSINGLENODE("SV")
NEXT
NEXT

BUT I CANNOT GET THE VALUES INTO Y AND SV.
IS MY LOGIC CORRECT OR IS THERE SOMETHING ELSE I CAN DO IT FOR IT.
I WANNA KNOW HOW DO I DO THE REFERENCE FOR GROUP_6
THANKS FOR UR HELP IN ADVANCE
 
Discover by yourself what went wrong and what is lacking. Here is the way to get them following closely your naming convention except when need more.
[tt]
set id=dom.selectnodes("/GROUP_1/GROUP_2")
for each subid in id
for each x in subid.selectnodes("GROUP_3/GROUP_4")
set y=x.selectsinglenode("CL")
'the CL_VALUE is retrieved here
cl_value=""
if not (y is nothing) then
cl_value=y.getAttribute("CL_VALUE")
end if
for each z in x.selectnodes("GROUP_5/GROUP_6")
set sv=z.selectsinglenode("SV")
sv_value=""
if not (sv is nothing) then
sv_value=sv.getAttribute("SV_VALUE")
end if
next
next
next
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top