The Processing Instruction Target Matching "[xX][mM][lL]" is Not Allowed
Posted May 18, 2006 at 7:18 AM by Ben Nadel
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.
What Other People Are Searching For
[ local search ]
[ local search ] cfxml remove whitespace
[ local search ] matching "[xx][mm][ll]"
[ local search ] processing instruction target matching
[ local search ] [xx][mm][ll]
[ local search ] the processing instruction target matching is not allowed
- Wanted: Full-Time ColdFusion Developer at Intoria Internet Architects
- Cold Fusion Senior Developer at Edge Information Management
- Back-End Web Developer-Information Technologist at Michigan State University
- ColdFusion Developer at Nonfat Media
- Mid-to-Senior Level Web Application Developer at SiteVision, Inc.
Thx that's help me to
No problem my man. Please feel free to contact me directly if you ever are stumped on a problem.
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...
An easier method is to simply use the 'trim' function :)
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. ;-)
Glad to help. Missed you at CFUNITED, my man.
Heh. *Someone* had to work that week! ;-)
Ha ha, thanks for taking one for the team :)
Why don't Adobe do the trimming of CR's etc as part of the function invocation.??
That's not a bad idea. That would be cool as part of XmlParse().
Thanks, helped me to quickly fix this issue (and move on to the next one ...).
Hey that did the trick... And I'm way off ColdFusion BTW (Doing some EJB over NB).
thanks a lot.. Really its a superb post. Got stuck from 2 hours, After seeign this sloved in few seconds..
Thnaks a lot :) :)
You rock! This is the 2nd stumper you have solved for me this week! Keep on blogging!!!!
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!
It can happens even if you have more than one prolog in the same xml
so remove all "<?xml ... ?>" after the first!!
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.
Interesting guys; I never thought of that case scenario. Thanks for pointing it out.
Thanks for your Help ...
Its done now ..
It works for me ..
This was something I never knew with XMLs, until I read your post! Thanks a lot! Helped me!
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))
@Niraj, @Prashanth, @JB,
Awesome! That's great to know this is still helping people.
I know this is an old post but saved me a ton of frustration today!
Ha ha, awesome.
it helped a lot
Thanks, man. You just got me out of trouble within seconds. :-)
Sweet - This fixed my problem! Thanks...
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" ) )
OOps, forgot the character in my character set:
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 :)
Sounds good - I'm glad you got it working.
well,that's help me too
Yeah, this definitely got drilled into my head. I never work with XML these days without trim()ing the value :)
Thank you... that solved a problem for me as well!!
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.
Thanks a lot!
No problem at all.
Thanks for the help, I had a space in the beginning of my xml.
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:
Thankyou a lot, man!!!
it helped me lot to fix the error: ( The processing instruction target matching "[xX][mM][lL]" is not allowed ). thanks a lot.
Thanks a Lot:)
Thanks .. really helped me from wasting a lot of time ..
It helped me so much. Thank you!
@Almir, @Somesh, @Swaroop, @Vijay, @Nior,
Glad this helped out!
Wow u post this help on 2006. When i started programming. Thx you have saved a noob :p
Sorry for my Bad english.
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:
<vxml version="2.0" xml:lang="en-US" application="AppRoot-vxml.jsp"
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
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"?>
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.
Finally your solution worked, thanks :)
Thanks for sharing this, I was having a same problem, you saved me a day. Thank you.
Thanks a lot Ben!
Can't count the times i've googled your blog!