Sign in to follow this  
apatriarca

[.net] null character in xml file

Recommended Posts

Hi, I have to parse an xml file generated by a program. That program have a bug and insert a null character (0x00) in the file. How can I parse that file using C#? The rest of the file is a valid xml file, so I only need a way to ignore that character.

Share this post


Link to post
Share on other sites
Simple answer, no. An xml file with a null character in it is not a valid xml file, so you can't parse it. You need to write characters like null as a standard html escape code.

Therefore you can
- Run a program after the buggy xml writer that reads in the xml and removes the null's (ie. rip-off's post-process idea)
- Read the xml into a stream, replace the null's, then parse the stream using the xmlreader (pre-process)
- Write your own custom xml parser

Share this post


Link to post
Share on other sites
Quote:
Original post by Headkazeescape code

Exactly why I'll never use XML again unless there is absolutely no alternative. Like when providing RSS feeds. XML has too many restrictions on what kind of characters may occur a file.

Share this post


Link to post
Share on other sites
Quote:
Original post by T1Oracle
Quote:
Original post by Headkazeescape code

Exactly why I'll never use XML again unless there is absolutely no alternative. Like when providing RSS feeds. XML has too many restrictions on what kind of characters may occur a file.

I doesn't like xml but I have no choice. I have solved the problem reading the file in a stream before parsing it and removing the null character when I find it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this