471,055 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,055 software developers and data experts.

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 2102
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by XML newbie: Urgent pls help! | last post: by
4 posts views Thread by XML newbie: Urgent pls help! | last post: by
reply views Thread by XML newbie: Urgent pls help! | last post: by
1 post views Thread by DBC User | last post: by
4 posts views Thread by a.kamroot | last post: by
8 posts views Thread by Andrew Smallshaw | last post: by

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.