An error occured while Parsing an XML document: Content is not allowed in prolog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Morag
    New Member
    • Dec 2007
    • 2

    An error occured while Parsing an XML document: Content is not allowed in prolog

    I need to retrieve some data from an xml document using a web server, it's not working so I took out everything that was not necessary and put everything back line by line until I hit the problem, I found out which line was causing the problem and so I've created a cfm to test it and it gets the error " Content is not allowed in prolog." Here's the test file:

    Code:
    <cfsilent>
    	<cfset xmlFileAddress = Expandpath("XMLcoursework.xml")>
    	<cffile action="READ" file="#xmlFileAddress#" variable="xmlObject">	
    	<cfset xmlDOM = "XMLParse(#xmlObject#)">
    
    	<cfset goalsForEXP = "//team[@id='1']/gf">
    	[B]<cfset goalsFor = XmlSearch(#xmlDOM#, #goalsForExp#)>[/B]
    
    </cfsilent>
    
    <html>
    	<head></head>
    	<body>
    		<cfoutput>#goalsFor#</cfoutput>
    	</body>
    </html>
    This line is causing the problem and I'm not sure why:

    Code:
    <cfset goalsFor = XmlSearch(#xmlDOM#, #goalsForExp#)>
    I have opened the xml file and its accompanying xsd file in a hex editor and there are no characters before

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    The xml and xsd files are both valid, I have tried dumping my xml onto the screen and that works fine, tried various different encodings, I have tried with diferent xpath expressions incase it was that, still the same error, I am new to this and completely stumped at this point, please somebody help me before I go crazy!
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Try [CODE=cfm]<cfset xmlDOM = "XMLParse(ToStr ing(xmlObject)) ">[/CODE]If that doesn't work, try saving using an editor with no formatting, e.g. Notepad.

    Comment

    Working...