Jump to content
  • Advertisement
Sign in to follow this  
apatriarca

[.net] null character in xml file

This topic is 4062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Could you not run the file through a post processor that strips out null characters, then you would have a valid XML file to work with.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!