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:
Launch code in new window » Download code as text file »
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.
Download Code Snippet ZIP File
Comments (8) | Post Comment | Ask Ben | Permalink | Other Searches | Print Page
[Macromedia][SQLServer JDBC Driver]Syntax error at token 0, line 0 offset 0
FireFox Fires OnClick Handler for Submit Buttons
Thx that's help me to
Posted by Tito on Aug 11, 2006 at 3:38 AM
No problem my man. Please feel free to contact me directly if you ever are stumped on a problem.
Posted by Ben Nadel on Aug 16, 2006 at 7:48 AM
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...
Posted by Ayusman on Dec 2, 2006 at 11:34 PM
An easier method is to simply use the 'trim' function :)
Example:
xmlParse(trim(myXMLdoc))
Posted by Neil Merton on Jan 3, 2007 at 6:56 AM
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.
Posted by Ben Nadel on Jan 3, 2007 at 7:11 AM
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.
Posted by wuxing on Jul 15, 2007 at 11:34 PM
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.
Posted by Reid on Aug 6, 2007 at 8:59 AM
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..!
Posted by sandeep on Nov 16, 2007 at 4:11 AM