A
Anthony P.
Hello Everyone,
I've not worked a lot with XML but I find myself working on a project
where I need to process a very simply formatted bit of it. After
doing research, I think using xmlTextReader is probably my best way to
go but I've run into a snag I'm hoping someone here can help me with.
First, let's look at the XML I'm processing:
<Response>
<name>David Gibson</name>
<age>27</age>
<date_of_birth>January 27, 2004</date_of_birth>
</response>
Pretty simple, right? So, now, I'm making a simple REST call which
returns that XML in a HTTPWebResponse object called "reader". I then
want to load all of the XML that the web response returns and then
walk it to see which name is returned. Here's what I'm doing:
Dim request as HTTPWebRequest
Dim response as HTTPWebResponse = Nothing
Dim reader as StreamReader
Dim xmlReturnString as String
request = DirectCast(WebRequest.Create("http://localhost/api.php?
record=1123"), HTTPWebRequest)
response = DirectCast(request.GetResponse(), HTTPWebResponse)
reader = new StreamReader(response.GetResponseStream())
'At this point, my reader object should contain the XML. I'll now move
that XML to a string object
xmlReturnString = reader.ReadToEnd()
'Now, I want to use xmlTextReader to check the name.
Dim xmlTxtReader as new xmlTextReader(xmlReturnString)
I'm going to stop here because the line of code above is where the
compiler errors. It tells me "Illegal character in path" but does not
explain why or what.
Can anyone offer me a helping hand here and clue me in as to what I am
doing wrong?
Thanks!
I've not worked a lot with XML but I find myself working on a project
where I need to process a very simply formatted bit of it. After
doing research, I think using xmlTextReader is probably my best way to
go but I've run into a snag I'm hoping someone here can help me with.
First, let's look at the XML I'm processing:
<Response>
<name>David Gibson</name>
<age>27</age>
<date_of_birth>January 27, 2004</date_of_birth>
</response>
Pretty simple, right? So, now, I'm making a simple REST call which
returns that XML in a HTTPWebResponse object called "reader". I then
want to load all of the XML that the web response returns and then
walk it to see which name is returned. Here's what I'm doing:
Dim request as HTTPWebRequest
Dim response as HTTPWebResponse = Nothing
Dim reader as StreamReader
Dim xmlReturnString as String
request = DirectCast(WebRequest.Create("http://localhost/api.php?
record=1123"), HTTPWebRequest)
response = DirectCast(request.GetResponse(), HTTPWebResponse)
reader = new StreamReader(response.GetResponseStream())
'At this point, my reader object should contain the XML. I'll now move
that XML to a string object
xmlReturnString = reader.ReadToEnd()
'Now, I want to use xmlTextReader to check the name.
Dim xmlTxtReader as new xmlTextReader(xmlReturnString)
I'm going to stop here because the line of code above is where the
compiler errors. It tells me "Illegal character in path" but does not
explain why or what.
Can anyone offer me a helping hand here and clue me in as to what I am
doing wrong?
Thanks!