Skip to main content
Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.

The Processing Instruction Target Matching "[xX][mM][lL]" is Not Allowed

By Ben Nadel on

I am starting to learn more about SOAP and XML in ColdFusion. Until now, I just haven't had much use of it. But now, I am dealing with web services that require SOAP requests and responses. Heck, I didn't even realize that ColdFusion has built in SOAP functions. But that's beside the point. I was trying to use the CFXML to create an XML object when I kept getting this error: ( The processing instruction target matching "[xX][mM][lL]" is not allowed ).

This error couldn't be less obvious. Luckily, after some quick googling I found the answer. Well, maybe not the answer, but a solution. It had to do with the document type declaration at the top: It was not the very first thing in the document - white space was. To fix this, I had to change the tag layout a bit to make the doc type come first:

<cfxml variable="REQUEST.Response"
	><?xml version="1.0" encoding="UTF-8"?>

As you can see, I wrap the end ">" of the CFXML tag to the next line so that there is no white space between it and the "<?" of the document type declaration. Another solution to this would be to do a CFSaveContent and then do a CFXml on the Trim() of that variable. Or even perhaps XmlParse on the Trim() of it.

No matter what, it's fun to be getting in to the SOAP stuff. I am working on a ColdFusion solution for the XStandard WYSIWYG editor. I thought the XStandard editor was cool before but now, I am really seeing how amazing powerful and yet flexible it is.

Reader Comments

Thanks for the information.
Really helped me a lot. I had unknowingly added blank space at the start of "<?xml version="1.0" encoding="ISO-8859-1"?>"
line in my web.xml file of the Tomcat server.

Saved alot of time...


True, Trim() is good so long as you have a stored XML string such as one stored via the CFSaveContent tag. However, this would require one extra step (the creation of the string THEN the parsing of it). But just taking out the white space in the beginning you can create AND parse the string in one step.

Both good options, especially depending on where you get the XML string from.

I got the same error when I modified a common xml document in Eclipse.
Finally I fixxed it by removing the leading space of the first line.

thanks for that, I had a comment at the start of my XML file and got this error, you just saved me a load of time.

Thanks a lot.. first thing when i got this error was to google and find out the solution..
finding out the white space would have consumed a lot of time...!!!

Ben, thanks for the post. I ran into the exact same error last night because I mistakenly placed a comment before the XML declaration. When I went to Google for assistance, it was nice to see someone I know pop up at the top of the list. ;-)

thanks a lot.. Really its a superb post. Got stuck from 2 hours, After seeign this sloved in few seconds..

Thnaks a lot :) :)

I concur with @Massimiliano. I ran into this last week. I generate temporary XML files with randomized names. The directory filled up and some of the "randomly named" files were reused, and the files were getting appended to. So there were basically two, well-formed xml bodies in one document. This was the error I got.

I came across your post after pulling out most of my hair.
Thanks for this post, you saved the last few strands. It works fine now :o))

I'm having this exact problem adn really struggling...

As mentioned above:

"It can happens even if you have more than one prolog in the same xml
so remove all "<?xml ... ?>" after the first!!"

Now my returned xml does indeed have multiple instances of <?xml version="1.0" encoding="UTF-8" standalone="no"?> within the string.

How do I get round this?




Sorry if this is an obvious question, but you don't have control over the generation of the, right? It's always easier to fix the output than to work around it.

Nope, it is an XML response generated by the Nominet EPP service.

Now I've cleaned it quite a bit already removing the ascii chars. etc but what I might try is replacing the </epp> with </epp>| and then looping over it to separate the response into three separate blocks...

At last! That little idea worked nicely and I now have xmlparse working on the three blocks. Probably not the most efficient method but considering I've spent the last week on this flipping thing I don't care! :D


You could probably also strip out ALL the meta tags in the beginning. I think the XML will parse fine without them. Something like:

trim( reReplace( yourXML, "<\?xml[^]+>", "", "all" ) )

Thanks Ben but the loop method actually works quite well as there is only 3-4 XML blocks returned each time.

I'm looping over them and stuffing the response into an array to return back to my calling page which is just the job :)

Ben, I have been working in Coldfusion for the better part of a year and a half. Your site has been an unending source of useful troubleshooting information. All my coworkers know your site (we always laugh when you have the answer to our question again. Keep up the good work-you make programming in Coldfusion a little less painful.


Thanks my man - that's wonderful to hear! Nothing makes me happier than to know this stuff I put up here is going to good use.

it helped me lot to fix the error: ( The processing instruction target matching "[xX][mM][lL]" is not allowed ). thanks a lot.

I am trying to save a wave file that was recorded in a VXML page and then passed in to my jsp page (audioSave-vxml.jsp). I get the xxmmll error after the code has already saved my file. The message says line 6 column 6 which is the space after "page and before "import". The first 6 lines are:
<?xml version="1.0"?>
<vxml version="2.0" xml:lang="en-US" application="AppRoot-vxml.jsp"
<%@page import="org.apache.commons.fileupload.*"%>

Any help would be appreciated.

Thanks, I ran into that 'target matching "[xX][mM][lL]" is not allowed' error and landed here, thanks Ben and all u guys

Thanks Ben!

I spent an hour finding out what was wrong ,

<?xml version="1.0" encoding="UTF-8"?> was not on the top :).

Hi i ran in the same error (The processing instruction target matching "[xX][mM][lL]" is not allowed) and i couldn't fix it even with the help this site provides. So please tell me whats wrong in my main.xml.

x <?xml version="1.0" encoding= "utf-8"?>
xmlns:android=" /res/android"
android:orentation="vertical" >

android:layout_height="wrap content"
android:text="vertical" >


I am still a beginner in programming and plus I don't know what the "white space" is so I'm stuck.

Oh and by the way in a way I do know what the "white space" means I mean I know it's the same than " ".But I just don't understand how could it fix my problem.

The easiest way to do anything regarding the options, is to backspace the first line to get rid of the white space. No need to type in anything.

hi i'm tying to start my appache tomcat server but at the time of server starting give an error in xml File at line :<?xml version="1.0" encoding="UTF-8"?>
before that line i was write u r above code likecfxml variable="REQUEST.Response"
> But also give an Error plz i want Solution

i have a problem in applicationContext.xml
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 10; The processing instruction target matching "[xX][mM][lL]" is not allowed.