I want to receive XML stream generated at another URL however when I
try to load the XML it errors out with one error or the other. I
beleive this XML comes back with HTTP header which actually comes back
as part of the response and obviously causes the
xmlDoc.Load(myR esponseStream) to break because the test preceding the
XML makes the xml invalid.
How can I remove this content from the receiving XML stream ?? Here is
some sample code :
..NET Page receiving response
sub Page_Load(sende r as object, e as Eventargs)
Dim wRequest As System.Net.Http WebRequest
Dim wResponse As System.Net.Http WebResponse
Dim StreamHandler As System.IO.Strea mReader
Dim xmlDoc As New System.Xml.XmlD ocument
Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebR equest.Create(U RL)
wRequest.Header s.Add("Man", "GET " & URL)
wResponse = CType(wRequest. GetResponse,
System.Net.WebR esponse)
If wRequest.HaveRe sponse Then
if wResponse.Statu sCode = Net.HttpStatusC ode.OK Then
streamHandler = New
System.IO.Strea mReader(wRespon se.GetResponseS tream())
xmlDoc.LoadXml( StreamHandler.R eadToEnd)
MsgBox("[--------" & xmlDoc.InnerTex t & "-------]")
End If
End If
'Catch ex As System.Net.WebE xception
Finally
End Try
end sub
I always get error at xmldoc.loadXML
Here is the Process.asp to which the call is being made above to send
XML stream.
<html><head> <title>proces s</title></head>
<body>
<form id="Form1" method="post" runat="server">
<script LANGUAGE="VBSCR IPT" runat="server" >
Response.Buffer =True
Response.Conten tType = "text/xml"
With Response
.Write("<?xml version='1.0' ?>" & chr(13))
.Write("<Record >")
.Write("<Name>" )
.Write("<Last> Jones </Last>")
.Write("<First> Kim </First>")
.Write("</Name>")
.Write("</Record>" )
End With
</script>
</form>
</body>
</html>
I would really appreciate any help on this.
try to load the XML it errors out with one error or the other. I
beleive this XML comes back with HTTP header which actually comes back
as part of the response and obviously causes the
xmlDoc.Load(myR esponseStream) to break because the test preceding the
XML makes the xml invalid.
How can I remove this content from the receiving XML stream ?? Here is
some sample code :
..NET Page receiving response
sub Page_Load(sende r as object, e as Eventargs)
Dim wRequest As System.Net.Http WebRequest
Dim wResponse As System.Net.Http WebResponse
Dim StreamHandler As System.IO.Strea mReader
Dim xmlDoc As New System.Xml.XmlD ocument
Try
Dim URL As String = "http://localhost/aspnet/process.asp"
wRequest = System.Net.WebR equest.Create(U RL)
wRequest.Header s.Add("Man", "GET " & URL)
wResponse = CType(wRequest. GetResponse,
System.Net.WebR esponse)
If wRequest.HaveRe sponse Then
if wResponse.Statu sCode = Net.HttpStatusC ode.OK Then
streamHandler = New
System.IO.Strea mReader(wRespon se.GetResponseS tream())
xmlDoc.LoadXml( StreamHandler.R eadToEnd)
MsgBox("[--------" & xmlDoc.InnerTex t & "-------]")
End If
End If
'Catch ex As System.Net.WebE xception
Finally
End Try
end sub
I always get error at xmldoc.loadXML
Here is the Process.asp to which the call is being made above to send
XML stream.
<html><head> <title>proces s</title></head>
<body>
<form id="Form1" method="post" runat="server">
<script LANGUAGE="VBSCR IPT" runat="server" >
Response.Buffer =True
Response.Conten tType = "text/xml"
With Response
.Write("<?xml version='1.0' ?>" & chr(13))
.Write("<Record >")
.Write("<Name>" )
.Write("<Last> Jones </Last>")
.Write("<First> Kim </First>")
.Write("</Name>")
.Write("</Record>" )
End With
</script>
</form>
</body>
</html>
I would really appreciate any help on this.
Comment