Verifying SymbolicXML Syntax
You can use the function XML`SymbolicXMLErrors to find errors with a SymbolicXML expression. This function returns a part specification which you can use with functions like Part or Extract to access the problematic part of your SymbolicXML expression. Let us return to the American League hitters from our earlier example.
We saw above that there were PlayerRecord nodes for which the Salary node contained the string "#N/A". Suppose we decide that any player whose salary is not available to use must be making $1,000,000. However, when we do our transformation, we make an easily overlooked mistake.
We have now created incorrect SymbolicXML. We have put the string "1000000" as the third element of the XMLElement expression, rather than a list containing that string. Suppose we did not know this, though, and that later on we find that Export produces errors when we try to write our modified XML to a file. We can use SymbolicXMLErrors to find the problematic expressions.
Notice that we first received XMLElement::name messages. These are our first indication that something is wrong, and we would have received these messages with just about any other function that processes SymbolicXML. The output of SymbolicXMLErrors, however, tells us exactly where something went wrong. ALerrors now contains a list of part specifications where the errors occurred. Here we examine the first error.
This problem is easy enough to fix.
We can see that the rest of the errors are of the same nature.
By using Map, we can fix the rest of the errors in the same way.
We can then verify that we have fixed our mistake using SymbolicXMLErrors again.