473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 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 4466
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.