Loop D Loop

T

Tim:..

Can someone please tell me what I'm doing wrong here

I'm trying to give the variable sStart a new name on each loo
EG
sStart1 = value1
sStart2 = value

however the following piece of code doesn't work

Thank

set oNodes=xml.selectNodes("/Project/Tasks/Task/Start"
for each oNode in oNode
sStart=oNode.tex
response.write("<BR>"
for i=0 to 10
response.Write(sStart(i)
nex
next
 
M

Maarten

You can't use sStart as singel variable and as list.
use myStart or something else
 
T

Tim:..

Something like this you mean

I get a Type mismatch: 'myStart

Any ideas? Thanks for the response but I could use a little more detailed discription

Thank

set oNodes=xml.selectNodes("/Project/Tasks/Task/Start"
for each oNode in oNode
sStart=oNode.tex
response.write("<BR>"
for i=0 to 10
myStart(i) = sStar
response.Write(myStart(i)
nex
next
 
M

Maarten

First: i know almost nothing about xml. I suppose you wish to retrieve the
notes in a xml file. But why you need the loop and the 101 times the name of
this node? Or do you want to cache the names of the nodes in strings? In
this case the name of the second node overwrites the first, etc...

Dim myNodes(200,100)

node=-1

set oNodes=xml.selectNodes("/Project/Tasks/Task/Start")

for each oNode in oNodes
node=node+1
for i=0 to 100
myNodes(node,i) = oNode.text
next
response.Write(myNotes(node,0)) & "<br>"
next
 
B

Bob Barrows [MVP]

Tim:.. said:
This doesn't work!

I think it might be because it is the XML messing it up! I have been
having serious problems with it!

I get an error:
Type mismatch: 'myNodes'

Thanks anyway!

We can't help without knowing the structure of your sml document. How about
posting a couple nodes so we know how to construct the xpath query.

Bob Barrows
 
B

Bob Barrows [MVP]

Tim:.. said:
Hi,

OK here is an extract from the XML document!

..XML..
<Project>
<Name>Test1</Name>
<Version>1.0</Version>
<Tasks>
<Task>
<ID>1</ID>
<Start>2004-03-26T08:00:00</Start>
<Finish>2004-03-28T17:00:00</Finish>
</Task>
<Task>
<ID>2</ID>
<Start>2004-03-29T08:00:00</Start>
<Finish>2004-03-30T17:00:00</Finish>
</Task>
..CODE..

Dim myNodes(200,100)

node=-1

set oNodes=xml.selectNodes("/Project/Tasks/Task/Start")

for each oNode in oNodes
node=node+1
for i=0 to 100
myNodes(node,i) = oNode.text
next
response.Write(myNotes(node,0)) & "<br>"
next

This code produces a Type Mismatch error for 'myNodes'
The Response.Write line does not look correct. For one thing: it says
"myNotes" instead of "myNodes". For another, don't use parentheses around
the response.write argument: it can only screw you up. Try this:
response.Write myNodes(node,0) & "<br>"

FWIW, when I use this code with your xml document:

set oNodes=xmldoc.selectNodes("/Project/Tasks/Task/Start")

for each oNode in oNodes
Response.Write oNode.text & "<BR>"
next

I get the desired results:
2004-03-26T08:00:00
2004-03-29T08:00:00

So we can be sure your xpath syntax is correct.

What is the goal here? I don't understand the purpose of the myNodes array.

Bob Barrows
 
C

Chris Hohmann

Bob Barrows said:
<Project>
<Name>Test1</Name>
<Version>1.0</Version>
<Tasks>
<Task>
<ID>1</ID>
<Start>2004-03-26T08:00:00</Start>
<Finish>2004-03-28T17:00:00</Finish>
</Task>
<Task>
<ID>2</ID>
<Start>2004-03-29T08:00:00</Start>
<Finish>2004-03-30T17:00:00</Finish>
</Task>

The Response.Write line does not look correct. For one thing: it says
"myNotes" instead of "myNodes". For another, don't use parentheses around
the response.write argument: it can only screw you up. Try this:
response.Write myNodes(node,0) & "<br>"

FWIW, when I use this code with your xml document:

set oNodes=xmldoc.selectNodes("/Project/Tasks/Task/Start")

for each oNode in oNodes
Response.Write oNode.text & "<BR>"
next

I get the desired results:
2004-03-26T08:00:00
2004-03-29T08:00:00

So we can be sure your xpath syntax is correct.

What is the goal here? I don't understand the purpose of the myNodes
array.

Once the Response.Write statement is fixed, the OP is likely to
encounter a "subscript out of range" error.

for i = 0 to 100

should read

for i = 0 to 99

Although I agree with Bob. I don't understand what the purpose of
myNodes is.

-Chris Hohmann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top