|
Prev: session variable
Next: Using cftransaction in a cfc
From: djc11 on 16 Apr 2008 19:00 Here is a url: https://midas.jnet.us/dc/cf_aim/testarb.cfm It is CF8. Here is the source: <cfxml variable="XMLSubscriptionRequest"> <?xml version="1.0" encoding="utf-8"?> <ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>xasdfasdfpJD</name> <transactionKey>xsdafdsafasdfjrx6</transactionKey> </merchantAuthentication> <refId>sample</refId> <subscription> <name>ProPlanner Subscription</name> <paymentSchedule> <interval> <length>12</length> <unit>months</unit> </interval> <startDate>2008-04-20</startDate> <totalOccurrences>9999</totalOccurrences> </paymentSchedule> <amount>500.00</amount> <payment> <creditCard> <cardNumber>4111111111111111</cardNumber> <expirationDate>2008-12</expirationDate> </creditCard> </payment> <customer> <id>test0001</id> <email>test(a)abc.com</email> <phoneNumber>555-555-5555</phoneNumber> </customer> <billTo> <firstName>Dustin</firstName> <lastName>Chesterman</lastName> <company>CFOTools.Net</company> <address>123 Main St</address> <city>Anytown</city> <state>CA</state> <zip>12345</zip> </billTo> </subscription> </ARBCreateSubscriptionRequest> </cfxml> <cfhttp method="POST" url="https://apitest.authorize.net/xml/v1/request.api" > <cfhttpparam type="Header" name="Accept-Encoding" value="deflate;q=0"> <cfhttpparam type="Header" name="TE" value="deflate;q=0"> <cfhttpparam name="body" type="xml" value="#ToString(XMLSubscriptionRequest)#" /> </cfhttp> <cfdump var="#cfhttp#"> <cfset model = '#ToString(Trim(cfhttp.fileContent))#'> <cfdump var="#model#"> <br /> <br /> <cfoutput>#ToString(model)#</cfoutput> <cfset model1 = XmlParse(model)> <cfdump var="#model1#">
From: PaulH **AdobeCommunityExpert** on 17 Apr 2008 01:40 that was harder then it should have been, should have realized this from the git go, sorry. its adding a BOM to the xml. its optional for UTF-8 & many s/w don't add it or even strip it out. frankly i don't know that xml is supposed to have this or not (and cf's xmlParse is doing the right thing). in any case: <cfset BOM=chr(65279)> <!--- utf-8 ONLY ---> <cfset z=replace(cfhttp.fileContent,BOM,"")> <cfdump var="#xmlParse(z)#">
From: BKBK on 17 Apr 2008 01:59 Djc11, Your latest post simply complicates matters. It is not clear what you want with it. For example, what does it have to do with the error? You seem to think PaulH is talking about your source code. When he says you should look at the source, he means the source in the browser. For example, in IE, the menu View => Source. To return to the [i]'content is not allowed in prolog'[/i] error, I noticed in an XML from authorize.net that there is an extra character at the beginning. I would therefore suggest that you first remove the characters in the beginning. Do something like the following. <cfset rawXml = cfhttp.filecontent> <cfset trimmedXml = trim(rawXml)> <cfset xmlFirstCharsRemoved = REREplaceNoCase(trimmedXml, "(.*<\?xml)", "<?xml")> <cfxml variable="xmlDoc"> <cfoutput>#xmlFirstCharsRemoved#</cfoutput> </cfxml> <cfdump var="#xmlDoc#">
From: djc11 on 17 Apr 2008 11:31 Thanks Paul, I looked for a BOM after reading another post, but didn't see one so i didn't even try it :-P Works perfect now. Thank you again! BKBK- I was making sure that i was calling xmlParse in the correct fashion. Thanks for you input though.
From: PaulH **AdobeCommunityExpert** on 17 Apr 2008 19:56
djc11 wrote: > Thanks Paul, I looked for a BOM after reading another post, but didn't see one > so i didn't even try it :-P Works perfect now. Thank you again! well you're not supposed to, but if you need to check write the content out w/cffile & use iso-8859-1 as the "charset". if you open that file in notepad you should see garbage (a question mark) before the 1st xml tag. if you use utf-8 as the "charset" you won't see anything but notepad will want to save that file as utf-8. after reading some W3C stuff on xml & BOMs i'm thinking that maybe xmlParse() should actually handle this. |