470,849 Members | 1,071 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

XmlReader, asp.net 2, and xmlexception help needed

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

May 17 '06 #1
5 4375
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.)

May 18 '06 #2
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.GetResponseStrea m());

}
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?
"Kevin Yu [MSFT]" wrote:
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.)

May 18 '06 #3


TdarTdar wrote:

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."


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
http://JavaScript.FAQTs.com/
May 18 '06 #4
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.
"Martin Honnen" wrote:


TdarTdar wrote:

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."


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
http://JavaScript.FAQTs.com/

May 18 '06 #5
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.)

May 22 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by CGuy | last post: by
2 posts views Thread by Rick Strahl [MVP] | last post: by
1 post views Thread by edi | last post: by
5 posts views Thread by George Durzi | last post: by
1 post views Thread by Angus Lepper | last post: by
1 post views Thread by BLUE | last post: by
5 posts views Thread by heday60 | last post: by
3 posts views Thread by =?Utf-8?B?RWQgS3JhbWVy?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.