Another XML Question (XMLException)

Hi Gang,

I’ve got an app that builds an XML file for an external parser requirement. I’ve just had to update the generated XML to include 4 new nodes. Prior to this change, this line worked properly to create a new copy of the built XML structure:

  myXMLDocument.LoadXml(theXML.ToString)

For some reason, that line now generates an XMLException error. Unfortunately, even removing the new node code, the error still persists.

I’m using a Try … Catch, but that just tells me what I already know - an XMLException occurred.

Is there are way to determine WHAT the actual exception is?

(RS12r2.1 or Xojo 14r2.1)

I had a similar problem when there were characters like <, >, etc that hadn’t been properly out into the XML file in the first place. To find it in the huge file, I had to slowly add bits of the XML file into a fresh file and when it died, I realized what happened.

I didn’t think XML.tostring would leave bad characters in it, but maybe it’s something similar? Or an encoding issue?

Ah -you may be onto something in the encoding aspect. The new test files all include UTF-8 international names in some of the sample fields.

That would explain why I get the error now even with the original code.

Digging … digging …

It was neither encoding nor reserved characters. One of the original nodes somehow got it’s name changed to 1ST from LST and the XML importer didn’t like a node element name that starts with a number.

While that is not going to be a problem with the code moving forward (I hope, since I have no idea how that got changed), shouldn’t the code to create the node element have barfed on setting a name that was invalid?

theNode = root.AppendChild(theXML.CreateElement("1ST")) value = theNode.AppendChild(theXML.CreateTextNode(tfStudioInfo(27).Text))