Click to See Complete Forum and Search --> : SelectSingelNode With Variables - Possible ?


Peter
08-04-2000, 06:56 AM
dim string
string = "ads"
set nod = domDoc.SelectSingleNode(string)

Is there SOME way of doing this ?
to use a string or something inside the "Selectsingelnode" ?

My problem is that i want
to chose a single node - without looping through
every node....like...

set nod = domDoc.SelectSingleNode("ads")
set nod = domDoc.SelectSingleNode("personal")
set nod = domDoc.SelectSingleNode("phone")
set nod = domDoc.SelectSingleNode("adress")

instead i want something like this....

for x = 1 to 40
set nod = domDoc.SelectSingleNode(string(x))

do something......
do something.....

next

Is this possible ? Please answer.....

Andy Holmes
08-08-2000, 03:22 AM
Peter,

I'm not too sure what you're wanting. Whether you want to select a
single node using a known string or whether you just want to retrieve
the values from the whole tree.

If you want to find a known value, specified in TagName, then try:
Dim pIDocument As New MSXML.DOMDocument
Dim pIRootNode As MSXML.IXMLDOMNode
Dim pINode As MSXML.IXMLDOMNode

If Not pIDocument.loadXML(Data) Then Err.Raise ....

Set pIRootNode = pIDocument.childnodes.Item(0)

Set pINode = pIRootNode.selectSingleNode(TagName)

--------------------

If you want to retrieve the values from the whole document then try:

Dim pIDocument As New MSXML.DOMDocument
Dim pINode As MSXML.IXMLDOMNode

Dim i As Integer

If Not pIDocument.loadXML(Data) Then Err.Raise ....

Set pINode = pIRootNode

For i = 0 to pINode.childNodes.length -1
If Not pIDocument.loadXML(Data) Then Err.Raise ....
Set pINode = pIDocument.childnodes.Item(i)
...
'Do Something
.....
Next i

--------------------


Hope this helps.

Andy