• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XML Post from Crystal Xcelcius

Explorer ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

I am needing to parse an XML post from Crystal Xcelcius with CF. Xcelsius sends the data as a form post, but CF doesn't see the form variable(s). Below is the XML (a sample) and code in VB that works to handle the post. I need to accomplosh the same thing with CF. Can you help me translate this to CF? Again, CF just doesn't see the form variable(s), so I am dead in the water.

I have tried referencing the post with the following variables: #form.data#, #form.PriceTable#, #PriceTable#, etc. CF doesn't see any of these as existing.

Here's the XML:

XML data sent: <data><variable name="PriceTable"><row><column>undefined</column><column>North</column><column>South</column><column>East</column><column>West</column></row><row><column>Wholesale</column><column>10</column><column>20</column><column>25</column><column>22.5</column></row><row><column>Markup</column><column>1</column><column>2</column><column>2.5</column><column>2.25</column></row><row><column>Retail</column><column>11</column><column>22</column><column>27.5</column><column>24.75</column></row><row><column>Units Sold</column><column>20</column><column>30</column><column>40</column><column>50</column></row></variable></data>

Here's the first part of the VB that works just fine...

'Get XML that was send from SWF file
Dim sXMLString

dim item as String
For Each item In Request.Form
'Response.Write(item & " = " & Request.Form(item) & VbCrLf)
sXMLString = sXMLString & item & " = " & Request.Form(item)
Next
TOPICS
Advanced techniques

Views

761

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

What do you get if you dump the form scope

<cfdump var="#form#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

Kevin: The Xcelsius post works in such a way that the page being posted to is not actually displayed in the browser. So, I can only see the results of my "script" (cf code). Here's my CF code on the page receivng the post:

<CFIF IsDefined("form")>
<cfset var_xmlData = "YES, we have a form">
<cfelse>
<cfset var_xmlData = "NOPE, no form">
</cfif>

<cffile action="write" file="C:\Inetpub\wwwroot\veritascdh\gtTest\xmlDataButton\data.xml"
output="#var_xmlData#" nameconflict="overwrite">

The data.xml file shows "Yes..."

So, then I tried:

<cfset var_xmlData = xmlParse(form, yes)>

But it does not work. We are close here. What do you advise?

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

The problem here is that you are trying to parse the form structure itself.

Based on what I'm seeing in the VB code, give this a shot.
<cfset xmlToParse = "">
<cfloop collection="#form#" item="i">
<cfset xmlToParse = xmlToParse & i>
</cfloop>

Try writing the xmlToParse to the file and see what you get, then run the xmlParse function.

<cfset var_xmlData = xmlParse(xmlToParse)>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

Thanks, but the code doesn't run. Here is exaclty what I have now:

<CFIF IsDefined("form")>
<cfset xmlToParse = "">
<cfloop collection="#form#" item="i">
<cfset xmlToParse = xmlToParse & i>
</cfloop>
<cfset var_xmlData = xmlParse(xmlToParse)>
<cfelse>
<cfset var_xmlData = "NOPE, no form">
</cfif>

<cffile action="write" file="C:\Inetpub\wwwroot\veritascdh\gtTest\xmlDataButton\data.xml"
output="#var_xmlData#" nameconflict="overwrite">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

One caveat, you may need to check to make sure that i is not equal to fieldnames

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

change

<cfset var_xmlData = xmlParse(xmlToParse)>

to
<cfset var_xmlData = xmlToParse>

And let me know what you get.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

When I view the data.xml file in the browser it shows:

The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource ' http://vhs0043/veritascdh/gttest/xmlDataButton/data.xm...

FIELDNAMES<DATA><VARIABLE NAME
^

Which is more output than I have been able to get up to this point.

The actual content of the data.xml file is simply:

FIELDNAMES<DATA><VARIABLE NAME

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

Ok, don't open it in the browser, open it in notepad. And I goofed too you need the value of i not i itself.

Add this to your code:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

OK, did that and and the code did not run, so I trided repalcing form with i as in:

<cfset xmlToParse = xmlToParse & i>

instead of

<cfset xmlToParse = xmlToParse & form>

with that the data.xml file contains only the following

<DATA><VARIABLE NAME

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

LATEST
Email me your code - if you can - schmidt <at> hungrycow . com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation