This post is just a little tip that I think can take a lot of time in trying to solve.
I was building a variable , using cfsavecontent, to process later on and there was absolutely nothing wrong with the code according to me, as below :-
<cfsavecontent variable="local.body"> <?xml version="1.0"?> <html><body> Just a test Email! </body></html> </cfsavecontent>
As you can see, its pretty hard to say if there is anything wrong with the code above. But I kept getting the error as soon the variable was passed to XmlParse().
After about 15 minutes, I google’d it and immediately came up with this post from Ben.Thanks Ben!
So, the solution is, there should be no characters (not even white space) before the starting XML. Or do a Trim() before passing it on to the XmlParse() but sometimes that option is not available because XmlParse could be sitting inside a service layer somewhere.
So, the code above really should be like this, notice the starting XML immediately after cfsavecontent :-
<cfsavecontent variable="local.body"><?xml version="1.0"?> <html><body> Just a test Email! </body></html> </cfsavecontent>
Its little things like this that sometimes eat up all your day.
#1 by Ben Nadel on February 17, 2009 - 10:07 pm
Quote
Another place where this has gotten me and is harder to debug is when you post SOAP XML to a web service using . Be sure to TRIM() the XML value you pass or the SOAP API might not parse it
#2 by Anuj Gakhar on February 17, 2009 - 11:16 pm
Quote
Thats right Ben. I always do that as a practice , but sometimes it just completely slips your mind, thats when posts like these come handy
#3 by Ben Nadel on February 17, 2009 - 11:23 pm
Quote
The frustrating thing is that web services will come back with such a general message like “400 bad request”. Grrrr!
#4 by Sonya on March 25, 2009 - 4:48 pm
Quote
OK…took out all the whitespace, but I am still getting the error. Any ideas?
#5 by Anuj Gakhar on March 26, 2009 - 9:52 am
Quote
@Sonya, did you try doing a trim() as well?
#6 by Dima on April 22, 2009 - 7:59 pm
Quote
Hi,
I still get this error message.
I don’t have any characters or white space before <?xml….
I added .trim() call before parsing the file. I, also, validated the xml file for well-formness in XML Spy.
Are there any other ideas for fixing this error?
I declare multiple schemas to validate the file. They are declared in the root element after the main xml declaration
Any help would be appreciated
Thanks
#7 by Anuj Gakhar on April 22, 2009 - 8:50 pm
Quote
@Dima, can I have a look at your code?
#8 by Dima on April 22, 2009 - 8:59 pm
Quote
Would it matter to a parser if the string that contains contents of xml file is all in upper case?
I think this is the issue for me.
I havent tested it yet
#9 by Anuj Gakhar on April 24, 2009 - 12:44 pm
Quote
@Dima, I dont think that should make a difference. Did you test it out?
#10 by Dima on April 24, 2009 - 4:58 pm
Quote
After some tests I found out that
the first line in the XML file
must be in lower case. Otherwise the same error shows up:
“The Processing Instruction Target
Matching “[xX][mM][lL]” is Not Allowed”
Also the tags in the schema should be the same case as the tags in the XML file.
Thanks for your help