|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
New to XMLIn 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 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 > > 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 > > > > > > |
|||||||||||||||||||||||