6 Replies Latest reply: Jun 22, 2012 9:13 AM by 12Robots RSS

    Use Of XmlFormat() in ColdFusion - 9

    Upen@Roul Community Member

      Hi All,


      I found that XmlFormat() function does the formatting of the any Xml text and removes any XML unsafe characters from that XML text.


      I just wrote below code to test this function.


      <cfsavecontent variable="x" >

      <?xml version = "1.0"?> 


          <someElement someAttribute="'a quoted value'"> 

             Body of element with <, >, "" and & goes here.






      <cfset x = XmlFormat(x) />


                y = XmlParse(trim(x));




      Then I got another error message

      An error occured while Parsing an XML document.

      Reference is not allowed in prolog.


      I know that by replacing the special characters from the XML text by string replace functions everything will be fine. But, I want to know what is the exact use of XmlFormat() function.



      Thanks in advance for any help.