Skip to main content
Participant
October 8, 2014
Question

how to format a not well formed xml into well formed

  • October 8, 2014
  • 1 reply
  • 677 views

Hi,

Here's what I'm trying to do: I have a build a report based on query results. In the query result, one field is a CLOB (which contains XML. The XML contains two tags - "description" and "count"). I want to read (&parse) the XML and store the "description" and "count" in a hashmap. But when I try to parse it, I end up in an error. I'm currently  using XmlParse but I got an error "The markup following the root element should be well formed."  I immediately used IsXml() to find out if the XML I am reading is well formed.  And the answer is "NO".

Could someone help me in converting it into a "well formed" one?

(This is what I've tried: I appended "<?xml version="1.0" encoding="UTF-8"?>" to the XML I'm reading coz it was missing this.  I later used XmlFormat to convert the XML into a string format.  But IsXML tells me that even this is not well formed.)

Thanks much for your help!

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    October 8, 2014

    XML encodes information is a specific way. Well-formedness determines whether or not a string is an XML document in the first place.

    However, as well-formedness can be broken by any arbitrary number of factors, it is in general impossible to automate the repair process to recover a well-formed XML document. You have to do it manually, using an XML or a text editor.