Skip to main content
Inspiring
April 16, 2008
Answered

problem with xmlParse()

  • April 16, 2008
  • 13 replies
  • 2396 views
I can not get around this problem... I have tried:
<cfset model = xmlParse(#cfhttp.fileContent#)>
<cfset model = xmlParse(cfhttp.fileContent)>
<cfset model = xmlParse(ToString(cfhttp.fileContent))>
<cfset model = xmlParse(Trim(cfhttp.fileContent))>
<cfset model = xmlParse(Trim(ToString(cfhttp.fileContent)))>

All of these give me the error : 'content is not allowed in prolog'...

What is the deal??? What is the syntax for this?
This topic has been closed for replies.
Correct answer Newsgroup_User
that was harder then it should have been, should have realized this from the git
go, sorry. its adding a BOM to the xml. its optional for UTF-8 & many s/w don't
add it or even strip it out. frankly i don't know that xml is supposed to have
this or not (and cf's xmlParse is doing the right thing).

in any case:

<cfset BOM=chr(65279)> <!--- utf-8 ONLY --->
<cfset z=replace(cfhttp.fileContent,BOM,"")>
<cfdump var="#xmlParse(z)#">

13 replies

djc11Author
Inspiring
April 16, 2008
I am having no luck with this. Do you see any problem with the sample XML above?
BKBK
Community Expert
Community Expert
April 17, 2008
Djc11,
Your latest post simply complicates matters. It is not clear what you want with it. For example, what does it have to do with the error?

You seem to think PaulH is talking about your source code. When he says you should look at the source, he means the source in the browser. For example, in IE, the menu View => Source.

To return to the 'content is not allowed in prolog' error, I noticed in an XML from authorize.net that there is an extra character at the beginning. I would therefore suggest that you first remove the characters in the beginning. Do something like the following.

djc11Author
Inspiring
April 16, 2008
It is the automatically generated XML from the chttp request response from Authorize.net. For an example, if i dump cfhttp.fileContent I get:

<?xml version="1.0" encoding="utf-8"?><ARBCreateSubscriptionResponse xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><refId>dus6073</refId><messages><resultCode>Error</resultCode><message><code>E00012</code><text>You have submitted a duplicate of Subscription 277440. A duplicate subscription will not be created.</text></message></messages></ARBCreateSubscriptionResponse>
djc11Author
Inspiring
April 16, 2008
Which one of the above formats should work?
Inspiring
April 16, 2008
djc11 wrote:
> All of these give me the error : 'content is not allowed in prolog'...

your xml is ill formed. look at the first few lines of it.