Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Loop D Loop

Reply
Thread Tools

Loop D Loop

 
 
Tim:..
Guest
Posts: n/a
 
      04-06-2004
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
 
Reply With Quote
 
 
 
 
Maarten
Guest
Posts: n/a
 
      04-06-2004
You can't use sStart as singel variable and as list.
use myStart or something else


 
Reply With Quote
 
 
 
 
Tim:..
Guest
Posts: n/a
 
      04-06-2004
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
 
Reply With Quote
 
Maarten
Guest
Posts: n/a
 
      04-06-2004
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



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-06-2004
Tim:.. wrote:
> 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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-06-2004
Tim:.. wrote:
> 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>
</Tasks>
</Project>
>
> ..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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      04-06-2004
"Bob Barrows [MVP]" <> wrote in message
news:%23gKsn7%...
> Tim:.. wrote:
> > 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>
> </Tasks>
> </Project>
> >
> > ..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.

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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Getting a loop to activate a loop above it Byte Python 4 03-24-2006 03:04 AM
Condition outside loop or separate loop for different condition? - Java 12 06-15-2005 08:50 AM
while loop in a while loop Steven Java 5 03-30-2005 09:19 PM
Loop the loop... =?Utf-8?B?VGltOjouLg==?= ASP .Net 2 02-16-2005 12:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57