469,271 Members | 876 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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

2
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:

Expand|Select|Wrap|Line Numbers
  1. <cfsilent>
  2.     <cfset xmlFileAddress = Expandpath("XMLcoursework.xml")>
  3.     <cffile action="READ" file="#xmlFileAddress#" variable="xmlObject">    
  4.     <cfset xmlDOM = "XMLParse(#xmlObject#)">
  5.  
  6.     <cfset goalsForEXP = "//team[@id='1']/gf">
  7.     <cfset goalsFor = XmlSearch(#xmlDOM#, #goalsForExp#)>
  8.  
  9. </cfsilent>
  10.  
  11. <html>
  12.     <head></head>
  13.     <body>
  14.         <cfoutput>#goalsFor#</cfoutput>
  15.     </body>
  16. </html>
This line is causing the problem and I'm not sure why:

Expand|Select|Wrap|Line Numbers
  1. <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

Expand|Select|Wrap|Line Numbers
  1. <?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!
Dec 18 '07 #1
1 9808
acoder
16,027 Expert Mod 8TB
Try
Expand|Select|Wrap|Line Numbers
  1. <cfset xmlDOM = "XMLParse(ToString(xmlObject))">
If that doesn't work, try saving using an editor with no formatting, e.g. Notepad.
Dec 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Dan | last post: by
5 posts views Thread by DU | last post: by
10 posts views Thread by Richard R Plourde | last post: by
1 post views Thread by Hang Cheng | last post: by
1 post views Thread by Silke Stuehler | last post: by
3 posts views Thread by moralbarometer | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.