all groups > dotnet xml > may 2006 >
You're in the

dotnet xml

group:

XmlReader, asp.net 2, and xmlexception help needed



XmlReader, asp.net 2, and xmlexception help needed TdarTdar
5/17/2006 11:57:02 AM
dotnet xml: Hello,
I am very new to the xmlreader in asp.net 2, I was just tring to read the
contents of is in the xml output. here is the sample code:

Dim settings As New XmlReaderSettings()
Dim reader As XmlReader
reader = XmlReader.Create(XMLOutput, settings)
While reader.Read()
If reader.IsStartElement() Then
If reader.IsEmptyElement Then
TextBox1.Text = TextBox1.Text + reader.Name
Else
TextBox1.Text = TextBox1.Text + reader.Name
reader.Read()
If reader.IsStartElement() Then
TextBox1.Text = TextBox1.Text + vbCr + vbLf +
reader.Name
End If
TextBox1.Text = TextBox1.Text + reader.ReadString()
End If
End If
End While


When this is run I get
"System.Xml.XmlException: The 'META' start tag on line 4 does not match the
end tag of 'HEAD'. Line 5, position 3."

I have to assume that this is something in the XMLOutput.

Is there a way to just raw dump everything in the string text of the
XMLOutput so I can see what is in it?

I tried
Response.Write(XMLOutput.ToString())

but I just get:
System.Xml.XmlTextReaderSystem.Xml.XmlTextReader


Ugh,
Tdar
RE: XmlReader, asp.net 2, and xmlexception help needed v-kevy NO[at]SPAM online.microsoft.com
5/18/2006 1:41:03 AM
Hi Tdar,

To get all the contents of XMLOutput, which is an XmlTextReader, you can
use ReadOuterXml method. If the XMLOutput's position is at the root node,
try

Response.Write(XMLOutput.ReadOuterXml())

HTH.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
RE: XmlReader, asp.net 2, and xmlexception help needed TdarTdar
5/18/2006 8:18:02 AM
Hi,
Well I still get an error even with what you sugested,
the error again is still The 'META' start tag on line 4 does not match the
end tag of 'HEAD'. Line 5, position 3.

The current code is:

Dim XE As New XMLExchange
Dim XMLOutput As XmlReader
XMLOutput = XE.sendXML(xmltosend.ToString)

If XMLOutput.IsEmptyElement Then
Response.Write("Element empty")
End If
If XMLOutput.IsStartElement() Then
Response.Write("Got here - start")
Response.Write(XMLOutput.ReadOuterXml())
End If
Response.Write(XMLOutput.ToString())
Dim XE As New XMLExchange
Dim XMLOutput As XmlReader
XMLOutput = XE.sendXML(xmltosend.ToString)
If XMLOutput.IsEmptyElement Then
Response.Write("Element empty")
End If
If XMLOutput.IsStartElement() Then
Response.Write("Got here - start")
Response.Write(XMLOutput.ReadOuterXml())
End If



THE xmlexchange(XE in my code) has this in it :
public XmlTextReader sendXML(string XMLtoSend)
{
XmlTextReader reader1 = null;
string text1 = this.APIurl + "?xml=" +
HttpUtility.UrlEncode(XMLtoSend);
this.RequestObject = (HttpWebRequest)WebRequest.Create(text1);
this.RequestObject.Accept = "text/xml";
this.RequestObject.ContentType = "application/x-www-form-urlencoded";
this.RequestObject.Method = "GET";
this.RequestObject.Timeout = 10000;
//this.RequestObject.Proxy = new WebProxy(this.ProxyString);
try
{
this.ResponseObject =
(HttpWebResponse)this.RequestObject.GetResponse();
reader1 = new XmlTextReader(this.ResponseObject.GetResponseStream());

}
catch (Exception exception1)
{
WebException exception2 = new WebException(exception1.Message);
throw exception2;
}

// return reader1;
return reader1;



is there any other way of seeing that I am getting sent to me?


[quoted text, click to view]
Re: XmlReader, asp.net 2, and xmlexception help needed TdarTdar
5/18/2006 10:12:01 AM
Well I don't know if it is well formed, this is why i want to see what is
there to see
what is wrong then i can report it to the company that makes the software
that is sending me the not well formed xml packet.


[quoted text, click to view]
Re: XmlReader, asp.net 2, and xmlexception help needed Martin Honnen
5/18/2006 5:30:26 PM


[quoted text, click to view]


[quoted text, click to view]

Is the XML you read in well-formed? It sounds simply as if it is not
well-formed and the reader gives the appropriate error message.


--

Martin Honnen --- MVP XML
RE: XmlReader, asp.net 2, and xmlexception help needed v-kevy NO[at]SPAM online.microsoft.com
5/22/2006 12:00:00 AM
Hi,

The error message means there are some error in the xml content or the xml
is invalid. In this case, I suggest you try to debug in the sendXML method.
Try to check XMLtoSend to see if there is anything wrong. Can it be loaded
to an XmlDocument?(Which means it is a valid xml string.)

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
AddThis Social Bookmark Button