Home All Groups Group Topic Archive Search About
Author
16 Nov 2004 8:58 PM
Wardeaux
Hey all, trying to cut my teeth on a simple XML parse... getting stumped...
In sample#1 I see boxes for "Response:", "A:1" ... as expected, but
In sample#2 I see boxes for "Response:", "B:2","C:2", and "Response"
In sample#3 I see boxes for "Response:", "A:","B:2","C:2", and "Response"
what's the difference? Why can't I get the "A:1" in the second and third
sample code?
MMTIA
wadeaux

CODE:
Sample #1:
Dim strResp, strXML As String
Dim xReader As Xml.XmlTextReader
strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
xReader = New Xml.XmlTextReader(New StringReader(strXML))
xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
xReader.Read()
MsgBox(xReader.Name)
xReader.Read()
MsgBox(xReader.Name & ":" & xReader.ReadString())

Sample #2

Dim strResp, strXML As String
Dim xReader As Xml.XmlTextReader

strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
xReader = New Xml.XmlTextReader(New StringReader(strXML))
xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
While xReader.Read()
    If (xReader.NodeType = Xml.XmlNodeType.Element) Then
        MsgBox(xReader.Name & ":" & xReader.ReadString())
    End If
End While

Sample #3

Dim strResp, strXML As String
Dim xReader As Xml.XmlTextReader

strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
xReader = New Xml.XmlTextReader(New StringReader(strXML))
xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
While xReader.Read()
        MsgBox(xReader.Name & ":" & xReader.ReadString())
End While

Author
16 Nov 2004 9:04 PM
Wardeaux
Sorry, the "C:2" boxes should be "C:3"...
wardeaux

Show quote
"Wardeaux" <warde***@bellsouth.net> wrote in message
news:ed3rE8BzEHA.1652@TK2MSFTNGP11.phx.gbl...
> Hey all, trying to cut my teeth on a simple XML parse... getting
stumped...
> In sample#1 I see boxes for "Response:", "A:1" ... as expected, but
> In sample#2 I see boxes for "Response:", "B:2","C:2", and "Response"
> In sample#3 I see boxes for "Response:", "A:","B:2","C:2", and "Response"
> what's the difference? Why can't I get the "A:1" in the second and third
> sample code?
> MMTIA
> wadeaux
>
> CODE:
> Sample #1:
> Dim strResp, strXML As String
> Dim xReader As Xml.XmlTextReader
> strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
> xReader = New Xml.XmlTextReader(New StringReader(strXML))
> xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
> xReader.Read()
> MsgBox(xReader.Name)
> xReader.Read()
> MsgBox(xReader.Name & ":" & xReader.ReadString())
>
> Sample #2
>
> Dim strResp, strXML As String
> Dim xReader As Xml.XmlTextReader
>
> strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
> xReader = New Xml.XmlTextReader(New StringReader(strXML))
> xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
> While xReader.Read()
>     If (xReader.NodeType = Xml.XmlNodeType.Element) Then
>         MsgBox(xReader.Name & ":" & xReader.ReadString())
>     End If
> End While
>
> Sample #3
>
> Dim strResp, strXML As String
> Dim xReader As Xml.XmlTextReader
>
> strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
> xReader = New Xml.XmlTextReader(New StringReader(strXML))
> xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
> While xReader.Read()
>         MsgBox(xReader.Name & ":" & xReader.ReadString())
> End While
>
>
Author
16 Nov 2004 9:42 PM
Wardeaux
OK... here's another update:
Found that when I call   MsgBox(xReader.Name & ":" & xReader.ReadString())
on the <response> node, it causes my app to ignore the "ReadString" for my
"A" node... How do I get around calling a "ReadString" on a node like
<Response>? Or is there a way to determine if <response> has a string to
display or just other nodes?
thanks!
wardeaux

Show quote
"Wardeaux" <warde***@bellsouth.net> wrote in message
news:%23%235dq$BzEHA.2752@TK2MSFTNGP11.phx.gbl...
> Sorry, the "C:2" boxes should be "C:3"...
> wardeaux
>
> "Wardeaux" <warde***@bellsouth.net> wrote in message
> news:ed3rE8BzEHA.1652@TK2MSFTNGP11.phx.gbl...
> > Hey all, trying to cut my teeth on a simple XML parse... getting
> stumped...
> > In sample#1 I see boxes for "Response:", "A:1" ... as expected, but
> > In sample#2 I see boxes for "Response:", "B:2","C:2", and "Response"
> > In sample#3 I see boxes for "Response:", "A:","B:2","C:2", and
"Response"
> > what's the difference? Why can't I get the "A:1" in the second and third
> > sample code?
> > MMTIA
> > wadeaux
> >
> > CODE:
> > Sample #1:
> > Dim strResp, strXML As String
> > Dim xReader As Xml.XmlTextReader
> > strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
> > xReader = New Xml.XmlTextReader(New StringReader(strXML))
> > xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
> > xReader.Read()
> > MsgBox(xReader.Name)
> > xReader.Read()
> > MsgBox(xReader.Name & ":" & xReader.ReadString())
> >
> > Sample #2
> >
> > Dim strResp, strXML As String
> > Dim xReader As Xml.XmlTextReader
> >
> > strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
> > xReader = New Xml.XmlTextReader(New StringReader(strXML))
> > xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
> > While xReader.Read()
> >     If (xReader.NodeType = Xml.XmlNodeType.Element) Then
> >         MsgBox(xReader.Name & ":" & xReader.ReadString())
> >     End If
> > End While
> >
> > Sample #3
> >
> > Dim strResp, strXML As String
> > Dim xReader As Xml.XmlTextReader
> >
> > strXML = "<response> <A>1</A><B>2</B><C>3</C></response>"
> > xReader = New Xml.XmlTextReader(New StringReader(strXML))
> > xReader.WhitespaceHandling = Xml.WhitespaceHandling.None
> > While xReader.Read()
> >         MsgBox(xReader.Name & ":" & xReader.ReadString())
> > End While
> >
> >
>
>

AddThis Social Bookmark Button