header image
Home arrow RealBasic Code arrow RealBasic Code arrow XML Error Finder
XML Error Finder PDF Print E-mail
Written by CrystalBallSoft Staff   
Aug 10, 2007 at 02:51 PM

Current Version: 1.0
Type: Example
License: Free
Requires: RB 5.5 or later

Find and Repair Errors in XML Files:
This application detects and repairs errors in an XML file that will cause RB to throw an XML Exception. Specifically this application searches for Ascii characters from 1 - 31 (not including Linefeed Character - 10 and Carriage Return Character - 13). These characters cause the XML tools in RB 5.5 to throw the exception when trying to parse the file.

Interestingly enough on the Mac, you can inadvertently enter these lower ascii characters by holding Control and typing a letter in a standard RB editfield. Therefore it is possible for a user to accidentally hit Control-(Letter) instead of Shift -(Letter)
and thereby insert a bad character into the editfield which will then get saved into the XML file. So the next time the file is read it will not be able to parse the file.

This very problem cause me some headaches in some of my apps, until I was finally able to track down the culprit.

This RB code also includes an example to demonstrate which Ascii values will cause an XML exception under different text encodings.

Works: OS X, Classic, Windows.

Download  

 

Last Updated ( Aug 10, 2007 at 02:56 PM )
RealBasic Code
RealBasic Code
Feel free to use this code with any of your RealBasic projects.  If you update any of them, let us know so that we can update our versions.