473,396 Members | 2,121 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,396 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 2170
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
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
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
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
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
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
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
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
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
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
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
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
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
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.