473,508 Members | 2,477 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(strXmlFileName,
FileMode.Open);
doc.Load(fs);

// Get the node list -- line below is where the error
occurs
XmlNodeList catalog = doc.GetElementsByTagName("product");
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 2176
Peter <em******@microsoft.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.com>
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
3064
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...
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...
0
5960
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...
4
4125
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...
0
1582
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...
1
9291
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...
4
4121
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...
3
1656
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...
8
3237
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...
0
7336
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,...
1
7066
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...
0
7504
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...
0
5643
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,...
1
5059
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...
0
4724
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...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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 ...
0
435
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...

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.