|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
XML DOM questions. in case anyone is looking...
I am trying to bone up on XML, and have been reading the tutorials posted here and W3S and others.
I am trying to parse through some XML files that have multiple siblings... But cannot seem to fins out how to get the DOM to see these siblings. here is an example PHP Code:
I have been using some of the DOM test examples but cannot seem to parse out the info from the statx siblings. I can get info from the higher level child nodes but nothing from the lower nodes. I am kind of stuck atm. code such as this: PHP Code:
will not show me the lowest level node info. |
|
#2
|
|||
|
|||
|
Your script is only iterating through the first level of children.
In order to get to the "root" of the problem (ha ha,) use this code instead: <script type="text/vbscript"> set xmlDoc=CreateObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note.xml") set xmlRootNode = xmlDoc.documentElement set xmlNodeList = xmlRootNode.selectNodes("/main/baseinfo/*") For i = 0 To xmlNodeList.length - 1 document.write(xmlNodeList.Item(i).nodeName & "<br />") Next </script> I haven't tested it, but the basic idea is, xpath a selectNodes statement to the level you need. I can give you more help or specifics if you need it.
__________________
- Chris of Custom Fit Technology http://www.customfittech.com Access to MySQL Conversion Tool, Visual XSLT Conversion Tool |
|
#3
|
|||
|
|||
|
Forgot this: If you want to cycle through all the children, create a recursive function.
|
|
#4
|
||||
|
||||
|
Thanks for the tips Custom, I will have to play with this this weekend, as these concepts are a tad new to me.
|
|
#5
|
|||
|
|||
|
I would be happy to email you some example VBScript code along with lists of necessary libraries if you require additional assitance.
|
|
#6
|
|||
|
|||
|
I'm having a similar problem with reading a file. The example you listed doesn't really apply to me. I searched and this was the closest thing I could find...
PHP Code:
I'm trying to get to the Question Text and the answers. Here's what I'm trying that's not working. PHP Code:
My error occurs here: PHP Code:
Any and all help would be appreciated. Thanks, Steve
__________________
Web Application Developer Autotrack XP Automobile Enthusiast QuickVWs.com K-Series.com |
|
#7
|
|||
|
|||
|
the error probably occurs because you're selecting a node object into a text variable. I would try something like
s_questxt = obj_question.selectSingleNode("QuestionText\text()") Or use a two step method to set x = node object, then get the text property of that object. I'm short on time right now so there's not a lot of code in this reply, but I hope it helps! |
|
#8
|
|||
|
|||
|
Thanks! I actually found the answer while I was playing around. Thanks,
Steve |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML DOM questions. in case anyone is looking... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|