How to read an XML Byte?

trevorjdaniel

Member
Joined
Sep 24, 2009
Messages
8
Programming Experience
1-3
Hello,

I am trying to work out how to read some xml that is being returned from an external URL.

Firstly, to get the XML response I have to send it some relevant information. I have done this with the following code:

VB.NET:
Dim url = "http://XX.XX.XX.XX/test"
        Dim client As New WebClient

        client.Headers.Add("Content-Type", "application/xml")
        Dim sentXml As Byte() = System.Text.Encoding.ASCII.GetBytes(xml.OuterXml)
        Dim response As Byte() = client.UploadData(url, "POST", sentXml)

When I check Fiddler, I can see that well formed XML is being returned and looking at the above code it seems to be stored as a byte in "response"

But I cannot work out how to now read this XML and returns the values within it.

Any help would be much appreciated

Thanks

Trev
 
System.Text.Encoding.ASCII.GetString method is the counterpart.
 
Brilliant! that worked perfectly. I know have the response as a sting variable using :

VB.NET:
Dim trev As String = System.Text.Encoding.ASCII.GetString(response)

I now need to pull out some values.. for example there is a node in the XML like the following

<PDSM>1.23</PDSM>

How would I do that please? Am I correct to have put it in a string?

Thanks for your help!

Much appreciated!

Trev
 
You can for example load a XDocument or XmlDocument and work with that.
 
Back
Top