Parse XML using coldfuison

I am trying to parse XML returned using Coldfusion but can not access an element that I need .

<cfset mydoc = XmlParse(result.returnedXML)>

This gives a structure that looks like attached:

I am trying to access the filed called cardTypeFile
LVL 19
erikTsomikSystem Architect, CF programmer Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Just go bit by bit down the tree ...

Try <cfdump var="#mydoc#">

It looks like the first container woudl be  

Then you can try to dump that to see what is next...

  <cfdump var="# mydoc['getTransactionDetailsResponse']#">

The next element looks like  


Then you can cfdump that...

The end result looks like it is located at....

erikTsomikSystem Architect, CF programmer Author Commented:
I tried  <cfdump var="#mydoc['getTransactionDetailsResponse']['transaction']#"> but getting an error message

Element transaction is undefined in a Java object of type class coldfusion.xml.XmlNodeList.
erikTsomikSystem Architect, CF programmer Author Commented:
if dump <cfdump var="#mydoc.XMLRoot#">

I get the following. THe file is attachedFile
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

erikTsomikSystem Architect, CF programmer Author Commented:
if I do <cfdump var="#mydoc.XMLRoot.xmlChildren#"> I get the following and then I am can not do anymore keep getting error FIle message
The next element is a number, see the green first column is an array 1, 2,...

So now dump...

and see what you have to grab next..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
erikTsomikSystem Architect, CF programmer Author Commented:
when I access first element I am getting the response, but my desired result in the second array position and if I ran
#mydoc.XMLRoot.xmlChildren[2]# getting an error message.

"'' The specific sequence of files included or processed
What do you mean by "ran" ?   If you do a cfdump on this you should see the next level, no?
<cfdump var="#mydoc.XMLRoot.xmlChildren[2]#">
erikTsomikSystem Architect, CF programmer Author Commented:
Got this far <cfdump var="#mydoc.XMLRoot.xmlChildren[2].xmlChildren[15].xmlChildren#">

And the array looks like this . Almost there Now got stock again
Its another array, see the green column, the next element is a [1]
erikTsomikSystem Architect, CF programmer Author Commented:
i have noticed some inconsistency in the return .

Can I do the search . If i do <cfdump var="#mydoc.XMLRoot.xmlChildren[2].xmlChildren#">

it goves me an array of n number of elelments. can i do the search to find array element with the name **payment**?
Pravin AsarPrincipal Systems EngineerCommented:
You can search for the particular element by XmlSearch function.


<cfset myElement=XmlSearch(xmlObject,"//cardType")>

Here is simple example, which parses XML data.

<cfset xmlFile =
'<?xml version="1.0" encoding="utf-8" ?>
<ResponseArray xmlns="urn:mdWebServiceAddress" xmlns:xsi="" xmlns:xsd="">
  <TransmissionReference />
  <Results />
  <Company>California Hospital Assocation</Company>
  <Name />
  <Address1>1215 K St</Address1>
  <Address2 />
  <Suite>Ste 900</Suite>
  <PrivateMailBox />
  <Code />
  <Description>Standard ZIP Code</Description>
  <Name>United States of America</Name>
  <Post />
  <Pre />
  <Name />
  <Range />
  <Garbage />

<cfset rssXml = xmlParse(xmlFile)>

<cffunction name="ReadXml" returntype="Any">
            <cfargument name="curNode" type="xml" />
            <cfsavecontent variable="readData">
                        <p>Type: #curNode.XmlType#</p>
                        <p>Name: #curNode.XmlName#</p>
                        <p>Value: #curNode.XmlText#</p>
                        <cfif ArrayLen(curNode.XmlChildren) gt 0>
                                    <p>No of Childern: #ArrayLen(curNode.XmlChildren)#</p>
                                    <cfloop index="ix" from="1" to="#ArrayLen(curNode.XmlChildren)#">
                              <p>No ChildNodes</p>
            <cfreturn #readData#/>

<!--- Root Element --->
<cfset rootElm = rssXMl.xmlRoot/>
<!--- Element Data --->
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.