Skip to main content
Ben Nadel at dev.Objective() 2015 (Bloomington, MN) with: Gabriel Perez
Ben Nadel at dev.Objective() 2015 (Bloomington, MN) with: Gabriel Perez ( @cfmsites )

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

By 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"?>
	<soap:Envelope
	...
	...
</cfxml>

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.

Want to use code from this post? Check out the license.

Reader Comments

1 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...

15,640 Comments

Neil,

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.

1 Comments

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.

1 Comments

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.

1 Comments

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...!!!
Thanks..!

3 Comments

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. ;-)

1 Comments

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

Thnaks a lot :) :)

1 Comments

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.

2 Comments

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))

7 Comments

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?

Cheers,

Phil

15,640 Comments

@Phil,

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.

7 Comments

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...

7 Comments

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

15,640 Comments

@Phil,

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" ) )

7 Comments

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

2 Comments

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.

15,640 Comments

@Zach,

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.

1 Comments

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

1 Comments

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"
xmlns="http://www.w3.org/2001/vxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd">
<%@page import="org.apache.commons.fileupload.*"%>

Any help would be appreciated.

1 Comments

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

1 Comments

Thanks Ben!

I spent an hour finding out what was wrong ,

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

2 Comments

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"?>
<LineralLayout
xmlns:android="http:schemas.android.com/apk /res/android"
android:layout_height"fill_parent"
android:layout_weight="fill_parent"
android:orentation="vertical" >

<TextView
anroid:layout_weight="fill_parent"
android:layout_height="wrap content"
android:text="vertical" >

<Button
android:layout_height="wrap_contetn"
android:layout_weight="wrap_contetn"
android:Text="@string/selfDestruct"
android:OnClick="SelfDestruct">
</LineralLayout>

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

2 Comments

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.

1 Comments

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.

1 Comments

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

1 Comments

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.

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel