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