Link to home
Start Free TrialLog in
Avatar of jeffmace
jeffmace

asked on

Check if XML Node Exists

In my previous question:
https://www.experts-exchange.com/questions/24131047/Geting-XML-Value-from-Nested-CFLOOP.html?cid=239&anchorAnswerId=23605044#a23605044

I had a XML file that I loop through and it winds up changing towards the end.  I want to know if there is a way to check if a node exists, if it does, continue the loop, if not, change to the next loop.  

Please view XML file in previous question.
<CFHTTP url="URL HERE" method="get">
<cfset xmlDoc = XMLParse(cfhttp.filecontent)>
<cfoutput>
  <cfloop from="1" to="#ArrayLen(xmlDoc.Demographics.response.pages.page)#" index="i">
    <strong>#xmlDoc.Demographics.response.pages.page[i].name.xmlText#</strong><br>
    <cfloop from="1" to="#ArrayLen(xmlDoc.Demographics.response.pages.page[i].tables.table)#" index="x">
      #xmlDoc.Demographics.response.pages.page[i].tables.table[x].name.xmlText#<br>
      <cfloop from="1" to="#ArrayLen(xmlDoc.Demographics.response.pages.page[i].tables.table[x].data.attribute)#" index="y">
        #xmlDoc.Demographics.response.pages.page[i].tables.table[x].data.attribute[y].name.xmlText#<br>
        <cfloop from="1" to="#ArrayLen(xmlDoc.Demographics.response.pages.page[i].tables.table[x].data.attribute[y].values)#" index="z">
         Neighborhood: #xmlDoc.Demographics.response.pages.page[i].tables.table[x].data.attribute[y].values[z].neighborhood.value.xmlText#<br>
         City: #xmlDoc.Demographics.response.pages.page[i].tables.table[x].data.attribute[y].values[z].city.value.xmlText#<br>
         Nation: #xmlDoc.Demographics.response.pages.page[i].tables.table[x].data.attribute[y].values[z].nation.value.xmlText#<br><br>
        </cfloop>
      </cfloop>
    </cfloop>
    <br>
    <br>
  </cfloop>
</cfoutput>

Open in new window

Avatar of Andrew Maurer
Andrew Maurer
Flag of United States of America image

Can you add the url to this so I can test it on my local before i submit an answer?
ASKER CERTIFIED SOLUTION
Avatar of Andrew Maurer
Andrew Maurer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jeffmace
jeffmace

ASKER

Absolutely SUPERB!!!!!