I have an XML string, XMLWebData which may or may not be structured correctly it may or may not be valid XML and need to load it into an XMLDocument. I am using the following:
XMLDoc = new XmlDocument(XMLWebData)
This is all fine unless as I said the XML is invalid and so the parser throws an error. What is the best way to check that XMLWebData is valid XML before creating my XML document?
XML parsers are required by the spec to completely reject documents that are not at least well-formed. (What isn’t well-formed isn’t XML.) The hope here is to at least be able to get an exception that Xojo can catch.
Yes well that is working now. It looks like it is parsing up to the (deliberately) malformed part of the XML. Its a pity it is not validated before it is parsed but I guess that would take 2 passes of the XML so I can see why not.