473,395 Members | 1,629 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,395 software developers and data experts.

load xml file containing header line

I use the following code to load xml file:

Dim srcXml As String = pathDataFiles & "test.xml"
Dim XmlDoc As New Xml.XmlDocument
XmlDoc.Load(srcXml)

If my xml file starts with the line -

<?xml version="1.0" ?>

I get -
An unhandled exception of type
'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.

Call Stack:
system.xml.dll!System.Xml.XmlTextReader.ParseTag() + 0x96b bytes

system.xml.dll!System.Xml.XmlTextReader.ParseRoot( ) + 0xed bytes
system.xml.dll!System.Xml.XmlTextReader.Read() + 0x80 bytes
system.xml.dll!System.Xml.XmlValidatingReader.Read WithCollectTextToken()
+ 0x93 bytes
system.xml.dll!System.Xml.XmlValidatingReader.Read () + 0x1b bytes
system.xml.dll!System.Xml.XmlLoader.LoadCurrentNod e() + 0x9e bytes
system.xml.dll!System.Xml.XmlLoader.LoadDocSequenc e(System.Xml.XmlDocume
nt parentDoc) + 0x32 bytes
system.xml.dll!System.Xml.XmlLoader.Load(System.Xm l.XmlDocument doc,
System.Xml.XmlReader reader, bool preserveWhitespace) + 0x6a bytes
system.xml.dll!System.Xml.XmlDocument.Load(System. Xml.XmlReader reader)
+ 0x49 bytes
system.xml.dll!System.Xml.XmlDocument.Load(string filename) + 0x51 bytes
myPrj.exe!mySln...myFunction(...) + 0xa0 bytes

If I comment-out these header line,
everything seems to work fine.

Question: How can I load a file containing this xml header line, without
getting any exceptions?

Thanks.

Atara.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
3 6220
* Atara <At***@DD.com> scripsit:
I use the following code to load xml file:

Dim srcXml As String = pathDataFiles & "test.xml"
Dim XmlDoc As New Xml.XmlDocument
XmlDoc.Load(srcXml)

If my xml file starts with the line -

<?xml version="1.0" ?>

I get -
An unhandled exception of type
'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.


I am not able to repro that. What encoding do you use to store the
file?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
The line should be:

<?xml version="1.0"?>

Note that there is no space before the final ?.
"Atara" <At***@DD.com> wrote in message
news:eQ****************@TK2MSFTNGP15.phx.gbl...
I use the following code to load xml file:

Dim srcXml As String = pathDataFiles & "test.xml"
Dim XmlDoc As New Xml.XmlDocument
XmlDoc.Load(srcXml)

If my xml file starts with the line -

<?xml version="1.0" ?>

I get -
An unhandled exception of type
'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.

Call Stack:
system.xml.dll!System.Xml.XmlTextReader.ParseTag() + 0x96b bytes

system.xml.dll!System.Xml.XmlTextReader.ParseRoot( ) + 0xed bytes
system.xml.dll!System.Xml.XmlTextReader.Read() + 0x80 bytes
system.xml.dll!System.Xml.XmlValidatingReader.Read WithCollectTextToken()
+ 0x93 bytes
system.xml.dll!System.Xml.XmlValidatingReader.Read () + 0x1b bytes
system.xml.dll!System.Xml.XmlLoader.LoadCurrentNod e() + 0x9e bytes
system.xml.dll!System.Xml.XmlLoader.LoadDocSequenc e(System.Xml.XmlDocume
nt parentDoc) + 0x32 bytes
system.xml.dll!System.Xml.XmlLoader.Load(System.Xm l.XmlDocument doc,
System.Xml.XmlReader reader, bool preserveWhitespace) + 0x6a bytes
system.xml.dll!System.Xml.XmlDocument.Load(System. Xml.XmlReader reader)
+ 0x49 bytes
system.xml.dll!System.Xml.XmlDocument.Load(string filename) + 0x51 bytes
myPrj.exe!mySln...myFunction(...) + 0xa0 bytes

If I comment-out these header line,
everything seems to work fine.

Question: How can I load a file containing this xml header line, without
getting any exceptions?

Thanks.

Atara.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #3
I think I found it, if the decleration does not start on the first-line,
first character, I get this exception.

conclusion: do not add blank lines before the xml declaration line...

Thanks anyway.

Atara

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: adpsimpson | last post by:
Hi, I have a file which I wish to read from C++. The file, created by another programme, contains both text and numbers, all as ascii (it's a .txt file). A sample of the file is shown below: <<...
5
by: G?nter Omer | last post by:
Hi there! I'm just trying to compile a header file (unsing Borland C++ Builder 10)implementing a class, containing the declaration of the STL <list> but it refuses to work. The following...
7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
5
by: Johnny Meredith | last post by:
I have seven huge fixed width text file that I need to import to Access. They contain headers, subtotals, etc. that are not needed. There is also some corrupt data that we know about and can...
36
by: Wei Su | last post by:
Hi, I have a text file abc.txt and it looks like: 12 34 56 23 45 56 33 56 78 ... .. .. ... .. .. I want to get how many rows totally in the text file, how to do this? Thanks.
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
by: giovanniparodi79 | last post by:
Hello everybody is there some utility to convert a raw image in an header file? Thanks everybody Gio
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
by: devquest | last post by:
I have an xml file, and I need to convert it into a text file. xml: <?xml version="1.0" encoding="UTF-8" ?> - <po-response xmlns="http://seller.marketplace.sears.com/oms/v1"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.