"Neal" <Neal@discussions.microsoft.com> wrote in message
news:E78992CB-1FA6-454B-90A6-5BBEBBA7B258@microsoft.com...
> Hi All
>
> I post a WebRequest, and the response is supposed to be delivered in XML
> format.
> posting the request in the browser address bar does return it..
> ie
>
> <?xml version="1.0" standalone="no" ?>
> ' <!DOCTYPE homearea (View Source for full doctype...)>
> '- <homearea base="
http://webedu.its.uct.ac.za:80"
> top_bar_background="#51657b" top_bar_title="#ffffff"
> ................................................................
> .........................................
> </homearea>
>
> I Using the following
> Dim result As WebResponse
> Dim req As WebRequest
> Dim RequestStream As Stream
> Dim ReceiveStream As Stream
> Dim encode As Encoding
> Dim sr As StreamReader
> Dim SomeBytes() As Byte
> Dim UrlEncoded As New StringBuilder()
> Dim reserved() As Char = {ChrW(63), ChrW(61), ChrW(38)}
>
> req = WebRequest.Create(url)
> req.Method = "POST"
> req.ContentType = "application/x-www-form-urlencoded" 'The
> ContentType property contains the media type of the request
>
> Dim strResult As String
>
> Try
> Dim i As Integer = 0
> If payload <> Nothing Then
> Dim j As Integer
>
>
> While i < payload.Length
> j = payload.IndexOfAny(reserved, i)
> If j = -1 Then
>
> UrlEncoded.Append(HttpUtility.UrlEncode(payload.Substring(i,
> payload.Length -
> i)))
> Exit While
> End If
>
> UrlEncoded.Append(HttpUtility.UrlEncode(payload.Substring(i, j - i)))
> UrlEncoded.Append(payload.Substring(j, 1))
> i = j + 1
> End While
> SomeBytes =
> System.Text.Encoding.UTF8.GetBytes(UrlEncoded.ToString())
> req.ContentLength = SomeBytes.Length
> RequestStream = req.GetRequestStream()
> RequestStream.Write(SomeBytes, 0, SomeBytes.Length)
> RequestStream.Close()
> Else
> req.ContentLength = 0
> End If
>
> I get the error
> " there is invalid data at the root level, line 1,position 1"
>
> when using XML Reader or XMLValidating Reader
> Dim xr As New XmlTextReader(New StreamReader(ReceiveStream,
> encode))
> xr.Normalization = False/True
> While xr.Read
> strResult = strResult & xr.ReadInnerXml
> '## error: there is invalid data at the root level,
> line
> 1,position 1
> End While
> End If
>
>
> Any and all help will be appreciated,
> this stuff is very new to me, and seriously fructrating.
> TIA
> --
> Neal Rogers
> University of Cape Town