I've been trying to teach myself XML. I have an XML file with contents like
this (from a play):
<SPEECH>
<SPEAKER>SLY</SPEAKER>
<LINE>I'll pheeze you, in faith.</LINE>
</SPEECH>
<SPEECH>
<SPEAKER>Hostes s</SPEAKER>
<LINE>A pair of stocks, you rogue!</LINE>
</SPEECH>
I've written the following code:
Dim nodeSpeeches As XmlNodeList
Dim node As XmlNode
nodeSpeeches = xmlDoc.SelectNo des("//SPEECH")
For Each node In nodeSpeeches
TempStr = node.SelectSing leNode("//SPEAKER").Child Nodes(0).Value
aIndex = GetSpeakerIndex (TempStr)
... Load data based on index
Next
It doesn't work. The value of SPEAKER is always the first occurrence in the
entire XML document instead of the current SPEECH node. The LINE count is
always the number of LINE elements in the entire document instead of the
current SPEECH.
It was my understanding that
For Each node In nodeSpeeches
would render node into an XML fragment holding only one <SPEECH>...</SPEECH>
for each iteration.
Why doesn't this work?
this (from a play):
<SPEECH>
<SPEAKER>SLY</SPEAKER>
<LINE>I'll pheeze you, in faith.</LINE>
</SPEECH>
<SPEECH>
<SPEAKER>Hostes s</SPEAKER>
<LINE>A pair of stocks, you rogue!</LINE>
</SPEECH>
I've written the following code:
Dim nodeSpeeches As XmlNodeList
Dim node As XmlNode
nodeSpeeches = xmlDoc.SelectNo des("//SPEECH")
For Each node In nodeSpeeches
TempStr = node.SelectSing leNode("//SPEAKER").Child Nodes(0).Value
aIndex = GetSpeakerIndex (TempStr)
... Load data based on index
Next
It doesn't work. The value of SPEAKER is always the first occurrence in the
entire XML document instead of the current SPEECH node. The LINE count is
always the number of LINE elements in the entire document instead of the
current SPEECH.
It was my understanding that
For Each node In nodeSpeeches
would render node into an XML fragment holding only one <SPEECH>...</SPEECH>
for each iteration.
Why doesn't this work?
Comment