Hi All
I want to read the text within an XML node based on its attributes. The problem is that the node text bit is accessible in the EndElement sub routine and the attributes are available in the StartElement bit.
In my example we have a node called "exit" which has an attribute of Title which is either North, South, East or West. I want to read that nodes Text in to a given variable, based on the title name.
Here's my code;
*******************************
sub xmlparser_endelement(blah)
If Name.ToLowerCase="exit" Then
If xmlParser.Parents.IndexOf("story") > -1 Then
Select Attributes.GetValue2("","title")
Case "north"
CurrentRoom.NorthDescription=Text.ToString
Case "south"
CurrentRoom.SouthDescription=Text.ToString
Case "east"
CurrentRoom.eastDescription=Text.ToString
Case "west"
CurrentRoom.westDescription=Text.ToString
End Select
End If
End If
end sub
*******************************
You can see that the line "Select Attributes.GetValue2("","title")" would fail because attributes aren't available in the endelement, but "Text" isn't available in Startelement.
Any ideas how I can get that working?
Olly
I want to read the text within an XML node based on its attributes. The problem is that the node text bit is accessible in the EndElement sub routine and the attributes are available in the StartElement bit.
In my example we have a node called "exit" which has an attribute of Title which is either North, South, East or West. I want to read that nodes Text in to a given variable, based on the title name.
Here's my code;
*******************************
sub xmlparser_endelement(blah)
If Name.ToLowerCase="exit" Then
If xmlParser.Parents.IndexOf("story") > -1 Then
Select Attributes.GetValue2("","title")
Case "north"
CurrentRoom.NorthDescription=Text.ToString
Case "south"
CurrentRoom.SouthDescription=Text.ToString
Case "east"
CurrentRoom.eastDescription=Text.ToString
Case "west"
CurrentRoom.westDescription=Text.ToString
End Select
End If
End If
end sub
*******************************
You can see that the line "Select Attributes.GetValue2("","title")" would fail because attributes aren't available in the endelement, but "Text" isn't available in Startelement.
Any ideas how I can get that working?
Olly