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

Posted May 18, 2006 at 7:18 AM by Ben Nadel

Tags: ColdFusion, XStandard WYSIWYG

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.




Reader Comments

Aug 11, 2006 at 3:38 AM // reply »
1 Comments

Thx that's help me to


Aug 16, 2006 at 7:48 AM // reply »
74 Comments

No problem my man. Please feel free to contact me directly if you ever are stumped on a problem.


Dec 2, 2006 at 11:34 PM // reply »
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...


Jan 3, 2007 at 6:56 AM // reply »
1 Comments

An easier method is to simply use the 'trim' function :)

Example:
xmlParse(trim(myXMLdoc))


Jan 3, 2007 at 7:11 AM // reply »
10,638 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.


Jul 15, 2007 at 11:34 PM // reply »
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.


Aug 6, 2007 at 8:59 AM // reply »
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.


Nov 16, 2007 at 4:11 AM // reply »
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..!


Jun 22, 2008 at 1:29 PM // reply »
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. ;-)


Jun 23, 2008 at 6:00 PM // reply »
10,638 Comments

@Matt,

Glad to help. Missed you at CFUNITED, my man.


Jun 27, 2008 at 5:35 AM // reply »
3 Comments

Heh. *Someone* had to work that week! ;-)


Jun 27, 2008 at 8:11 AM // reply »
10,638 Comments

Ha ha, thanks for taking one for the team :)


Jul 2, 2008 at 6:17 AM // reply »
5 Comments

Why don't Adobe do the trimming of CR's etc as part of the function invocation.??


Jul 2, 2008 at 8:19 AM // reply »
10,638 Comments

@Martin,

That's not a bad idea. That would be cool as part of XmlParse().


Jul 31, 2008 at 2:59 AM // reply »
1 Comments

Thanks, helped me to quickly fix this issue (and move on to the next one ...).


Aug 1, 2008 at 2:28 PM // reply »
1 Comments

Hey that did the trick... And I'm way off ColdFusion BTW (Doing some EJB over NB).

Thanks!


Jan 5, 2009 at 2:14 AM // reply »
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 :) :)


Jan 28, 2009 at 9:24 AM // reply »
3 Comments

You rock! This is the 2nd stumper you have solved for me this week! Keep on blogging!!!!


Jan 28, 2009 at 9:26 AM // reply »
10,638 Comments

@MDriscoll,

Awwwww yeaaaaah!


Jan 28, 2009 at 3:57 PM // reply »
14 Comments

Thank you thank you! these are the small things that can eat your whole day, or make it - in this case you just made mine much easier!


May 29, 2009 at 10:48 AM // reply »
1 Comments

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

bye


May 29, 2009 at 2:56 PM // reply »
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.


Jun 1, 2009 at 8:30 AM // reply »
10,638 Comments

@Massimiliano, @Brian,

Interesting guys; I never thought of that case scenario. Thanks for pointing it out.


Jul 25, 2009 at 3:38 AM // reply »
1 Comments

Thanks for your Help ...

Its done now ..

It works for me ..


Aug 14, 2009 at 3:08 AM // reply »
1 Comments

This was something I never knew with XMLs, until I read your post! Thanks a lot! Helped me!


JB
Sep 11, 2009 at 9:55 AM // reply »
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))


Sep 12, 2009 at 9:57 PM // reply »
10,638 Comments

@Niraj, @Prashanth, @JB,

Awesome! That's great to know this is still helping people.


Sep 16, 2009 at 10:05 AM // reply »
24 Comments

I know this is an old post but saved me a ton of frustration today!


Sep 18, 2009 at 4:58 PM // reply »
10,638 Comments

@Aaron,

Ha ha, awesome.


Dec 22, 2009 at 2:39 AM // reply »
1 Comments

it helped a lot


Dec 22, 2009 at 8:11 AM // reply »
1 Comments

Thanks, man. You just got me out of trouble within seconds. :-)


Jan 11, 2010 at 2:04 PM // reply »
1 Comments

Sweet - This fixed my problem! Thanks...


Feb 1, 2010 at 2:17 PM // reply »
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


Feb 1, 2010 at 6:22 PM // reply »
10,638 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.


Feb 2, 2010 at 4:50 AM // reply »
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...


Feb 2, 2010 at 4:59 AM // reply »
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


Feb 4, 2010 at 10:10 PM // reply »
10,638 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" ) )


Feb 4, 2010 at 10:11 PM // reply »
10,638 Comments

OOps, forgot the character in my character set:

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


Feb 5, 2010 at 3:11 AM // reply »
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 :)


Feb 6, 2010 at 6:07 PM // reply »
10,638 Comments

@Phil,

Sounds good - I'm glad you got it working.


Mar 16, 2010 at 1:19 AM // reply »
1 Comments

well,that's help me too


Mar 17, 2010 at 10:13 AM // reply »
10,638 Comments

@Panda,

Yeah, this definitely got drilled into my head. I never work with XML these days without trim()ing the value :)


Apr 20, 2010 at 11:00 AM // reply »
22 Comments

Thank you... that solved a problem for me as well!!


May 20, 2010 at 12:57 PM // reply »
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.


May 20, 2010 at 8:25 PM // reply »
10,638 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.


May 30, 2010 at 11:00 PM // reply »
1 Comments

Thanks a lot!


Jun 7, 2010 at 10:28 PM // reply »
10,638 Comments

@Andy,

No problem at all.


Aug 28, 2010 at 12:24 AM // reply »
1 Comments

Thanks for the help, I had a space in the beginning of my xml.


Sep 5, 2010 at 1:59 PM // reply »
10,638 Comments

@Bobby,

No problem at all. I've found that storing the return value in a CFSaveContent-type tag and then streaming it to the client via CFContent really helps to get around this problem:

http://www.bennadel.com/blog/1762-CFContent-Variable-Response-vs-Standard-Output-Response.htm


Jan 4, 2011 at 5:11 PM // reply »
1 Comments

Thankyou a lot, man!!!


Apr 8, 2011 at 8:13 AM // reply »
1 Comments

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


Apr 24, 2011 at 4:27 PM // reply »
1 Comments

Thanks a Lot:)


May 5, 2011 at 4:08 PM // reply »
1 Comments

Thanks .. really helped me from wasting a lot of time ..


Jun 4, 2011 at 3:45 PM // reply »
1 Comments

It helped me so much. Thank you!


Jun 4, 2011 at 5:59 PM // reply »
10,638 Comments

@Almir, @Somesh, @Swaroop, @Vijay, @Nior,

Glad this helped out!


Jun 30, 2011 at 9:45 AM // reply »
1 Comments

Wow u post this help on 2006. When i started programming. Thx you have saved a noob :p
Sorry for my Bad english.


Oct 5, 2011 at 2:20 PM // reply »
1 Comments

Thanks !!!


Oct 18, 2011 at 10:13 AM // reply »
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.


Nov 11, 2011 at 4:51 AM // reply »
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


Dec 9, 2011 at 8:23 AM // reply »
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 :).


Jan 24, 2012 at 8:01 AM // reply »
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.


Jan 25, 2012 at 10:12 AM // reply »
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.



Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Feb 3, 2012 at 10:49 PM
How I Got Node.js Running On A Linux Micro Instance Using Amazon EC2
Wow this was really helpful! Only thing I would add is you need to update your .bash_profile after you edit the secure_path. This is what I did: $ . ~/.bash_profile Otherwise, NPM won't be found. ... read »
Feb 3, 2012 at 10:14 PM
Pushing Base64-Encoded Images Over HTML5 WebSockets With Pusher And ColdFusion
@Ben, Just wanted to let you know that pusher are soon to start limiting sizes on messages. This was the detail that came through in the Feb dispatch: "However, we will soon be limiting the s ... read »
Feb 3, 2012 at 5:05 PM
Regular Expressions Make CSV Parsing In ColdFusion So Much Easier (And Faster)
I tried using your RegEx in my C# program, but it was matching an extra empty-string at the end and so I would end up with an extra field that doesn't exist, so I changed it to this: (^|,)("(?: ... read »
Feb 3, 2012 at 3:47 PM
ColdFusion Supports HTTP Verbs PUT And DELETE (As Well As GET And POST)
Josh Cyr posted this on Twitter just a little bit ago. Thought it was appropriate. http://stackoverflow.com/questions/1619152/how-to-create-rest-urls-without-verbs/1619677#1619677 ... read »
Feb 3, 2012 at 2:28 PM
Changing The Execution Context Of Your Self-Executing Function Blocks In JavaScript
@Michael, You definitely make a good point (and extra points for quoting movies - I love movies). When you use a return() statement to define the object's public API, it does provide a consistent a ... read »
Feb 3, 2012 at 2:04 PM
Changing The Execution Context Of Your Self-Executing Function Blocks In JavaScript
To quote Jurassic Park: "Just because you can doesn't mean you should". I completely, utterly disagree with the thought that this is more readable. Consider the current module pattern: if ... read »
Feb 3, 2012 at 1:10 PM
REST API Design Rulebook By Mark Masse
@Jordan, Yeah, WRML was created by Mark Masse (author of the book). I also found it to be a bit convoluted. I suppose it is intended to allow the Client to be able to programmaticaly respond to cha ... read »
Feb 3, 2012 at 1:08 PM
ColdFusion Supports HTTP Verbs PUT And DELETE (As Well As GET And POST)
@Jason, To be honest, I don't have good answers for that kinds of stuff. And, to the point, that is specifically why I *really* liked the REST API Design Rulebook by Mark Masse - he just cuts throu ... read »