473,666 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error in XML structure. How to skip node and continue using XmlDocument

Hello,

I am having trouble processing an XML file that contains
an error on one of the nodes. How can I instruct the .NET
framework to skip the node and continue when it comes
across a node that contains an error? Please advise.
This is the error:
Hexadecimal value 0x1C is an invalid character
Line 5810, position 83
// Here is my code
XmlDocument doc = new XmlDocument();
FileStream fs = new FileStream(strX mlFileName,
FileMode.Open);
doc.Load(fs);

// Get the node list -- line below is where the error
occurs
XmlNodeList catalog = doc.GetElements ByTagName("prod uct");
P.S - The XML data file is coming from a third party so
we cannot fix the error in it, we just have to deal with
it.
Jul 21 '05 #1
1 2189
Peter <em******@micro soft.com> wrote:
I am having trouble processing an XML file that contains
an error on one of the nodes. How can I instruct the .NET
framework to skip the node and continue when it comes
across a node that contains an error? Please advise.


I would expect that to be really pretty difficult, unfortunately. What
I suggest you do is work out a way to correct the document on its way
in - write a filtering stream which just gets rid of the invalid bytes
(or use a reader and get rid of the invalid characters). XML parsers
are typically not designed to do error correction, only error
detection.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2

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

Similar topics

1
3072
by: Hazz | last post by:
I have 5 tables in SQL Server. Each with the following design and a sample chain of the relationships from the root (WRL - World) UUS is the 'Code' of the first table and it is the 'Parent' value of the second table, etc. Parent varchar 3 Name varchar 60 Code varchar 3 WRL United States UUS <- UUS California UCA <- UCA North Coast UNC <- UNC
1
415
by: Peter | last post by:
Hello, I am having trouble processing an XML file that contains an error on one of the nodes. How can I instruct the .NET framework to skip the node and continue when it comes across a node that contains an error? Please advise. This is the error: Hexadecimal value 0x1C is an invalid character
0
5968
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku in advance When I run the pgm , I get the error: Can't parse login information. Namespace Manager or XsltContext needed. This query has a prefix, variable or userdefined function. I have added the Try-catch in all my functions. In...
4
4142
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku in advance When I run the pgm , I get the error: Can't parse login information. Namespace Manager or XsltContext needed. This query has a prefix, variable or userdefined function. I have added the Try-catch in all my functions. In...
0
1597
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku in advance When I run the pgm , I get the error: Can't parse login information. Object Reference not set to an instance of an object. I have added the Try-catch in all my functions. In ParseLoginResponse function, it catches the above...
1
9300
by: DBC User | last post by:
Hi, I am using MTOM and WSE 2.0 and trying to upload a file which is almost 70MB (big). I have setup the timeout to a good size and file size limit to 100MB in the server. The uploading is coming through T3 pipe. Even with all the changes, I get a 'out of memory' error. Can someone help? In my code, I am reading the file into a byte array. I don't think reading the byte array has any problem.
4
4137
by: a.kamroot | last post by:
Hi I need to exchange XML formated information between two methods in my C# program. I have been trying to play with XMLNode and XMLElement but without much success. I think I want to stop now and understand the xml classes in C# (rather in dot net) before proceeding further. Can any one point me to such a resource ? Or even a primer on XML, which explains the definitions of nodes, elements and attributes ?
3
1684
by: raghudr | last post by:
Hi all, I am parsing a .xml file.My main intention is to retrieve the name value of node "Signal":- "Name Value" which is "rag". i want to store only the <signal"name value" that is only "rag" ,"rock","yahoo"to my list. I do not want to add any <subsignals"name value" to the list.i want
8
3242
by: Andrew Smallshaw | last post by:
I'm working on a data structure that began life as a skip list derivative, but has evolved to the point that it now only has a passing resemblance to them. Each node of this structure has a few constant size variables (ints and the like), an array holding the actual data (chars in this case) and a random number of pointers to other nodes in the structure. At the moment my code uses a fixed size array for the contents (which may or may...
0
8363
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
8883
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
8645
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
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...
1
6203
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
5672
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
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
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
2
2013
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.