473,799 Members | 3,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 XmlReaderSettin gs()
Dim reader As XmlReader
reader = XmlReader.Creat e(XMLOutput, settings)
While reader.Read()
If reader.IsStartE lement() Then
If reader.IsEmptyE lement Then
TextBox1.Text = TextBox1.Text + reader.Name
Else
TextBox1.Text = TextBox1.Text + reader.Name
reader.Read()
If reader.IsStartE lement() Then
TextBox1.Text = TextBox1.Text + vbCr + vbLf +
reader.Name
End If
TextBox1.Text = TextBox1.Text + reader.ReadStri ng()
End If
End If
End While
When this is run I get
"System.Xml.Xml Exception: 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.ToStr ing())

but I just get:
System.Xml.XmlT extReaderSystem .Xml.XmlTextRea der
Ugh,
Tdar

May 17 '06 #1
5 4480
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.ReadO uterXml())

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(xmlt osend.ToString)

If XMLOutput.IsEmp tyElement Then
Response.Write( "Element empty")
End If
If XMLOutput.IsSta rtElement() Then
Response.Write( "Got here - start")
Response.Write( XMLOutput.ReadO uterXml())
End If
Response.Write( XMLOutput.ToStr ing())
Dim XE As New XMLExchange
Dim XMLOutput As XmlReader
XMLOutput = XE.sendXML(xmlt osend.ToString)
If XMLOutput.IsEmp tyElement Then
Response.Write( "Element empty")
End If
If XMLOutput.IsSta rtElement() Then
Response.Write( "Got here - start")
Response.Write( XMLOutput.ReadO uterXml())
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.Url Encode(XMLtoSen d);
this.RequestObj ect = (HttpWebRequest )WebRequest.Cre ate(text1);
this.RequestObj ect.Accept = "text/xml";
this.RequestObj ect.ContentType = "applicatio n/x-www-form-urlencoded";
this.RequestObj ect.Method = "GET";
this.RequestObj ect.Timeout = 10000;
//this.RequestObj ect.Proxy = new WebProxy(this.P roxyString);
try
{
this.ResponseOb ject =
(HttpWebRespons e)this.RequestO bject.GetRespon se();
reader1 = new XmlTextReader(t his.ResponseObj ect.GetResponse Stream());

}
catch (Exception exception1)
{
WebException exception2 = new WebException(ex ception1.Messag e);
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.ReadO uterXml())

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.Xml Exception: 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.Xml Exception: 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?(Wh ich 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
5424
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 valid root node or not. How do I do this? This is what I need if(File.Exists(fileName)) {
2
2404
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 7:32:39 pm</time>
1
1851
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
3067
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
2314
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: Public Class Form1 Inherits System.Windows.Forms.Form
1
2161
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
3190
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 dir.GetFiles("*.xml")) { try { ParseXML(file.FullName); }
0
2453
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 follows while(reader.Read()) { ... } System.Xml.XmlException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3. Unfortunately I...
3
3535
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 up and going and I decided to start testing 'disaster' scenarios. For example, you start up but your file has been deleted, or you try to save and the file is read only. Or you lack write permissions. Or you try to load
0
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.