473,385 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Element vs Node?

I am trying to pull data from child nodes but I cannot find the syntax that
works. I think I may be confusing elements and nodes? I want to get the
value of the items in the <Sched> child nodes. The relevant part of my code
are below as well as a part of the source xml.
=============== Code ==============================

Dim objDom As DOMDocument
Dim y As IXMLDOMElement
Dim x As IXMLDOMElement
Dim j as Integer

Set objDom = New DOMDocument
objDom.async = False
objDom.Load (inputfile)
Set objRootElement = objDom.documentElement
For Each x In objRootElement.childNodes
........
Select Case x.childNodes.Item(j).nodeName
......
Case "Sched"
For Each y In x.childNodes.Item(j) '<==== Error: "object
doesn't support this property or method"
xxx = y.childNodes.Item(1).Text
Next
Next

================ Sample XML ================
<?xml version="1.0" ?>
<root>
<base>
<SeqNbr>1</SeqNbr>
<PorF>P</PorF>
<Round>1</Round>
<Sched>
<ID>10</ID>
<Nickname>Group A</Nickname>
<Class>AAA</Class>
</Sched>
<Sched>
<ID>23</ID>
<Nickname>Group J</Nickname>
<Class>AAA</Class>
</Sched>
</base>
<base>
<SeqNbr>2</SeqNbr>
<PorF>F</PorF>
<Round>0</Round>
<Sched>
<ID>16</ID>
<Nickname>Group C</Nickname>
<Class>AA</Class>
</Sched>
<Sched>
<ID>27</ID>
<Nickname>Group D</Nickname>
<Class>AA</Class>
</Sched>
</base>

<base>
<SeqNbr>3</SeqNbr>
<PorF>P</PorF>
<Round>4</Round>
<Sched>
<ID>31</ID>
<Nickname>Group F</Nickname>
<Class>BB</Class>
</Sched>
<Sched>
<ID>23</ID>
<Nickname>Group G</Nickname>
<Class>BB</Class>
</Sched>
</base>


Nov 12 '05 #1
2 4874
"Wayne Wengert" <wa***************@wengert.com> wrote in message news:Ob**************@tk2msftngp13.phx.gbl...
I am trying to pull data from child nodes but I cannot find the syntax that
works. I think I may be confusing elements and nodes?
More likely, the confusion is between singular and plural.
Select Case x.childNodes.Item(j).nodeName
......
Observe here that x.childNodes.Item( j) has one nodeName.
This suggests it's "one" item.
Case "Sched"
For Each y In x.childNodes.Item(j) '<==== Error: "object
doesn't support this property or method"


Here you are doing a For Each, which requires an enumerable
object like IXMLDOMNodeList (a list of nodes). However, you
are specifying x.childNodes.Item( j) which is an IXMLDOMNode
(individual node). Because it's a singular object, the "method" it
doesn't support is being enumerated.

I'm taking a guess that what you might want is..

' The children of <Sched>
For Each y In x.childNodes.Item( j).childNodes
Wayne, you might also be able to find better/faster answers in
microsoft.public.xml, since your question concerns VBScript
and MSXML (and isn't really about the .NET Framework's
XML stack).
Derek Harmon
Nov 12 '05 #2
Derek;

Thanks for the reply. I suspect your observation is right on. I'll go back
and try to re-think that whole process with your advice in mind.

Wayne

"Derek Harmon" <lo*******@msn.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
"Wayne Wengert" <wa***************@wengert.com> wrote in message

news:Ob**************@tk2msftngp13.phx.gbl...
I am trying to pull data from child nodes but I cannot find the syntax that works. I think I may be confusing elements and nodes?


More likely, the confusion is between singular and plural.
Select Case x.childNodes.Item(j).nodeName
......


Observe here that x.childNodes.Item( j) has one nodeName.
This suggests it's "one" item.
Case "Sched"
For Each y In x.childNodes.Item(j) '<==== Error: "object doesn't support this property or method"


Here you are doing a For Each, which requires an enumerable
object like IXMLDOMNodeList (a list of nodes). However, you
are specifying x.childNodes.Item( j) which is an IXMLDOMNode
(individual node). Because it's a singular object, the "method" it
doesn't support is being enumerated.

I'm taking a guess that what you might want is..

' The children of <Sched>
For Each y In x.childNodes.Item( j).childNodes
Wayne, you might also be able to find better/faster answers in
microsoft.public.xml, since your question concerns VBScript
and MSXML (and isn't really about the .NET Framework's
XML stack).
Derek Harmon

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Derek Basch | last post by:
Hello All, I ran into a problem while dynamically constructing XHTML documents using minidom. If you create a script tag such as: script_node_0 = self.doc.createElement("script")...
4
by: Jean-Christophe Michel | last post by:
Hi, In a complex merging of two (non ordered) xml files i need to keep track of the elements of the second tree that were already merged with first tree, to copy only unused elements at the end....
3
by: Kae Verens | last post by:
I apologise if this is the wrong newsgroup for this. I'm working on a CMS backend, and am having trouble getting IE6 to behave. I have a large script which works perfectly in Firefox, but does...
5
by: Patient Guy | last post by:
In my reading of the Strict and Transitional DTD for HTML 4.0, the table row (TR) elements are contained within table section elements: THEAD, TFOOT, and TBODY. The table section elements are...
1
by: jason.lucey | last post by:
Hi, I cannot get this figured out. I need to get the text out of an element node. In IE, I can do it like this: xNode(0).text but that does not work for Mozilla. And since element nodes...
1
by: pjeung | last post by:
Say that I have an element <elementA> that has several layers of subelements. In System.Xml.XmlDocument and related classes, how do I rename <elementA> to <elementB> leaving the subelements intact?
14
by: hgraham | last post by:
Hi, I'm trying to understand how to work the dom, and all I'm trying to do is insert a link right before another link in the html based on it's href value. This isn't a real world example - I'm...
8
by: bennett.matthew | last post by:
Hello all, This is probably an elementary (no pun intended) question, but I've spent all afternoon on it and it's driving me crazy. I have a function which dynamically adds to a table. It...
4
by: Alan T | last post by:
I used XmlDocument to load from a file. Then how do I append an element to the end? <files> <file> <name>graphic.txt</name> <location>c:\temp</location> </file>
4
by: jaime.dyson | last post by:
Hello all, I have the unenviable task of turning about 20K strangely formatted XML documents from different sources into something resembling a clean, standard, uniform format. I like...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.