472,958 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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 4453
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: CGuy | last post by:
Hi, I am using an XmlTextReader to read an xml file. It may happen that the file is present in the disk, but it may be empty (0 bytes). I would like to find out whether the xml file contains a...
2
by: Rick Strahl [MVP] | last post by:
Hi all, I need a reality check <g>... I have the following XML fragment: <event sitename="West Wind Demo Link"> <url>http://rasnotebook/wconnect/testpage.wwd?Test2</url> <time>11/17/2003...
1
by: edi | last post by:
Hi, I have MS .Net Framework v1.1.4322. I have this XML file: <?xml version="1.0" ?> <!--here there are two spaces at the beginning--> <aaa> <a id="1"> <Dept>Finance</Dept>
5
by: George Durzi | last post by:
Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I do that? Thanks!
1
by: Angus Lepper | last post by:
I'm writing a stock ticker for a stock market simulation, and can load the data into the xmlreader in the first place, but can't figure out how to refresh/update the data in it. Any ideas? Code:...
1
by: BLUE | last post by:
In a property i do this: .... catch(XmlException e) { throw new XmlException("Error processing configuration file!",e); } Then I catch it in another class: catch(XmlException e) {
5
by: heday60 | last post by:
I've got this application that watches a directory for XML's and then parses them into a DB. It then moves them based on if the XML was succesful or a bad XML... foreach(FileInfo file in...
0
by: gpet44 | last post by:
Hi, I have a problem receiving XML over a NetworkStream in C# .Net 2.0/3.0. I'm creating an XMLReader from the stream. I get the following exception when the XmlReaderreads from the stream as...
3
by: =?Utf-8?B?RWQgS3JhbWVy?= | last post by:
I thought this might be useful for someone... I was doing a little work earlier using an Xmldocument class to create & maintain a minor store of data in Xml format. I'd gotten the whole thing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.