Sometimes when you copy and paste a special character from the internet, some control-bytes can end up in your FileMaker file. For FileMaker this is not a problem, but since these control-bytes are illegal characters according to the XML standard, FMVersion won't be able to parse your XML when you use the API or the "Save a copy as XML" option.
This guide will help you find and remove the illegal bytes from your FileMaker file.
Step 1: Generate a XML using Save a Copy as XML...
To learn how to generate a XML file using Save a Copy as XML visit this link.
Step 2: Open the XML with the Google Chrome browser
When you have generated your XML you can open the file with Google Chrome, and you will see something like the following picture:
As you see Google Chrome also shows us something is wrong with the generated XML. If we then open the page inspector (Mac OSX: Option+Command+i, Windows: Shift+Control+i), make sure you click the "Elements" tab. In the inspector you should fold open the "Structure"-tag and the "AddAction"-tag until you see something like the following:
The last child-element of the AddAction is the catalog that contains our illegal byte. In the case of the example it is the "FieldsForTables" tag. If we open the catalog until you have opened a tag called "ObjectList" you can see all the elements contained within this catalog:
The last child-element of the ObjectList-tag contains the illegal byte. In the case of the example that would be the field with id 6 and the name "IllegalByteField".
Step 3 Open the FileMaker file and navigate to the troubling element
Now that we know the name of the element that generates the error, we can find it in FileMaker. The field in our example contains the following calculation:
Now we only have to find the control-byte in this calculation and delete it. The problem is, however, that a control-byte is invisible in FileMaker. To solve this issue we can download Sublime Text 3 and paste the calculation there. Sublime Text 3 will show all hidden control-bytes as their hexadecimal value like this:
In the example you can see at line 6 a <0x1e> character. Remove that character and copy the new calculation back into the FileMaker field.
Step 4 Repeat step 1, 2 and 3
Now that we have removed the first illegal byte from our FileMaker file, it could be possible there are still more illegal bytes in our file. So repeat step 1, 2 and 3 until Google Chrome shows the entire XML as it should be.