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

Reading XML

New Here ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

Have the following page that gets returned to me when

I submit a form, but I'm not sure how to parse out the values so I can insert them into a table.

Thanks in advance for the help!

https://commerce.cashnet.com/cashnetb/Gateway/htmlgw.aspx?refvalue=137114-275071&client=UCLA_PROD&pa...

TOPICS
Advanced techniques

Views

650

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

correct answers 1 Correct answer

Guide , Jan 19, 2011 Jan 19, 2011

On a matter of irritating principle I try not to just give people answers, as I'm paid to do my own job and I'd rather see people learn. But here's a hint:

Use CFHTTP with the url you gave, a method of GET and a result parameter.

Parse the result.FileContent using xmlParse().

Use CFDUMP to look at that structure. then break down the struct until you get what you're after.

Votes

Translate

Translate
Guide ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

Hmm, thanks for your login credentials and everything, but you're looking to parse XML? Have you tried the XMLParse() function at all?

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
New Here ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

It's just a dummy site for an example...

I haven't ever worked with XMLParse() I read the language reference but not sure I understand what's going on...

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
Guide ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

In which case without wanting to sound patronising, you'll really need to get a firm grip on CF before you start moving XML data into a database. It's a simple process once you're used to CF structs, but without actually doing the work for you no-one will really be able to help you much more at this stage.

Put simply, XmlParse() simply parses any XML data and turns it into a CF struct. You can then do with it any of the standard functions you can do with structs.

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
LEGEND ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

Which bit don't you understand? What code have you used to experiment with getting it working?

Did you read the section of the docs (there's a link on the xmlParse() page) detailing how to work with XML in CF?

xmlParse():

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6e90.html

Using XML and WDDX

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7fb3.html

--
Adam

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
New Here ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

It seems insanly complicated to me. Any way you could show me by example by just extracting <respmessage>Success</rspmessage>? From there I can figure out how to do the whole thing, I'm just kinda lost...

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
Guide ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

On a matter of irritating principle I try not to just give people answers, as I'm paid to do my own job and I'd rather see people learn. But here's a hint:

Use CFHTTP with the url you gave, a method of GET and a result parameter.

Parse the result.FileContent using xmlParse().

Use CFDUMP to look at that structure. then break down the struct until you get what you're after.

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
New Here ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

Yup, got all that:

<cfhttp url="https://commerce.cashnet.com/cashnetb/Gateway/htmlgw.aspx" method="Get" port="80" resolveurl="false" timeout="120">
<cfhttpparam type="formfield" name="refvalue" value="137114-275071">
<cfhttpparam type="formfield" name="client" value="UCLA_PROD">
<cfhttpparam type="formfield" name="password" value="cash1234">
<cfhttpparam type="formfield" name="operator" value="web">
<cfhttpparam type="formfield" name="command" value="inquiry">
</cfhttp>

<cfset variables.fileContent = XmlParse(cfhttp.fileContent)>

<cfdump var="#variables.fileContent#">

See result at: https://shib.hhs.ucla.edu/CashNetLookup/01CashNetUpdate.cfm

My problem is how to get all the info out of this document...

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
New Here ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

For some reason it doesn't work when clicking on this link, but if you copy and paste it you'll see what I'm trying to extract.

https://shib.hhs.ucla.edu/CashNetLookup/01CashNetUpdate.cfm

Any help getting resmessage from this would be appreciated.

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
Enthusiast ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

LATEST

the dump from that page pretty much explains how you access that value:

fileContent.cngateway.respmessage retrieves the "respmessage" XML element,

fileContent.cngateway.respmessage.xmlText (really, believe what cfdump is

telling you) gets it's value, "SUCCESS".

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