471,595 Members | 990 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

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:

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#)">
  6.     <cfset goalsForEXP = "//team[@id='1']/gf">
  7.     <cfset goalsFor = XmlSearch(#xmlDOM#, #goalsForExp#)>
  9. </cfsilent>
  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 9975
16,027 Expert Mod 8TB
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
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.