473,663 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(src Xml)

If my xml file starts with the line -

<?xml version="1.0" ?>

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

Call Stack:
system.xml.dll! System.Xml.XmlT extReader.Parse Tag() + 0x96b bytes

system.xml.dll! System.Xml.XmlT extReader.Parse Root() + 0xed bytes
system.xml.dll! System.Xml.XmlT extReader.Read( ) + 0x80 bytes
system.xml.dll! System.Xml.XmlV alidatingReader .ReadWithCollec tTextToken()
+ 0x93 bytes
system.xml.dll! System.Xml.XmlV alidatingReader .Read() + 0x1b bytes
system.xml.dll! System.Xml.XmlL oader.LoadCurre ntNode() + 0x9e bytes
system.xml.dll! System.Xml.XmlL oader.LoadDocSe quence(System.X ml.XmlDocume
nt parentDoc) + 0x32 bytes
system.xml.dll! System.Xml.XmlL oader.Load(Syst em.Xml.XmlDocum ent doc,
System.Xml.XmlR eader reader, bool preserveWhitesp ace) + 0x6a bytes
system.xml.dll! System.Xml.XmlD ocument.Load(Sy stem.Xml.XmlRea der reader)
+ 0x49 bytes
system.xml.dll! System.Xml.XmlD ocument.Load(st ring 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 6236
* 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(src Xml)

If my xml file starts with the line -

<?xml version="1.0" ?>

I get -
An unhandled exception of type
'System.Xml.Xml Exception' 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******** ********@TK2MSF TNGP15.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(src Xml)

If my xml file starts with the line -

<?xml version="1.0" ?>

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

Call Stack:
system.xml.dll! System.Xml.XmlT extReader.Parse Tag() + 0x96b bytes

system.xml.dll! System.Xml.XmlT extReader.Parse Root() + 0xed bytes
system.xml.dll! System.Xml.XmlT extReader.Read( ) + 0x80 bytes
system.xml.dll! System.Xml.XmlV alidatingReader .ReadWithCollec tTextToken()
+ 0x93 bytes
system.xml.dll! System.Xml.XmlV alidatingReader .Read() + 0x1b bytes
system.xml.dll! System.Xml.XmlL oader.LoadCurre ntNode() + 0x9e bytes
system.xml.dll! System.Xml.XmlL oader.LoadDocSe quence(System.X ml.XmlDocume
nt parentDoc) + 0x32 bytes
system.xml.dll! System.Xml.XmlL oader.Load(Syst em.Xml.XmlDocum ent doc,
System.Xml.XmlR eader reader, bool preserveWhitesp ace) + 0x6a bytes
system.xml.dll! System.Xml.XmlD ocument.Load(Sy stem.Xml.XmlRea der reader)
+ 0x49 bytes
system.xml.dll! System.Xml.XmlD ocument.Load(st ring 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
5234
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: << LEDAR V1.3 - Real Time Detection >> <LEFT 144> <TOP 165> <RIGHT 265> <BOTTOM 376>
5
8703
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 errors occure: "test.h" line 29 type name expected "test.h" line 29 declaration missing
7
3529
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. How do i make the last pointer in the indirect sector that has another level of indirect pointer, and be defined recursively to support infinite large files? -code-
5
11567
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 correct once the data is in Access (or during the import process itself). Furthermore, the text files are poorly set up, such that some records may be "shifted" over a few characters, and therefore the fixed width nature of the file is corrupted. ...
36
3580
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
3932
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. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
13
12103
by: giovanniparodi79 | last post by:
Hello everybody is there some utility to convert a raw image in an header file? Thanks everybody Gio
1
6476
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" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
2
2989
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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://seller.marketplace.sears.com//SellerPortal/s/schema/oms/purchaseorder-v1.xsd"> - <purchase-order> <po-number>2180031</po-number> <po-date>2009-12-27</po-date> ...
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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
8858
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
8771
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
8548
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,...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.