[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 949
  • Last Modified:

How do I parse a SOAP document in ColdFusion?

Hi,

I'm consuming a .NET SOAP-based web service that returns the following SOAP document utilizing cfhttp.  How would I parse the following document into a ColdFusion object such as a query, array, struct, etc.? I could do with even a simplified XML document.  Thanks!!

//assignment
<cfset parsedResult = XmlParse(cfhttp.FileContent)>

//actual SOAP result set
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><QueryResponse xmlns="http://YourWDSLHere.com/webservice/2008"><QueryResult><WebServiceResult><Type>NDC</Type><Key>0006-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0006-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>EMEND CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>MERCK AND CO INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0006-0464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0006-0464-05</Value></Pair><Pair><Name>TradeName</Name><Value>EMEND CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>MERCK AND CO INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0006-0464-10</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0006-0464-10</Value></Pair><Pair><Name>TradeName</Name><Value>EMEND CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>MERCK AND CO INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>49288-0464-5</Key><ResultSet><Pair><Name>NDCCode</Name><Value>49288-0464-5</Value></Pair><Pair><Name>TradeName</Name><Value>SPONDYLOCLADIUM INJECTION SOLUTION</Value></Pair><Pair><Name>FirmName</Name><Value>ANTIGEN LABORATORIES INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-01</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-05</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-30</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-30</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-60</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-60</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-90</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-90</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>62794-464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>62794-464-01</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE .25 MG TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN BERTEK PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>62794-464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>62794-464-05</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE .25 MG TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN BERTEK PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>62794-464-88</Key><ResultSet><Pair><Name>NDCCode</Name><Value>62794-464-88</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE .25 MG TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN BERTEK PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>63739-464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>63739-464-05</Value></Pair><Pair><Name>TradeName</Name><Value>FUROSEMIDE INJECTION</Value></Pair><Pair><Name>FirmName</Name><Value>MCKESSON PACKAGING SERVICES BUSINESS UNIT MCKESSON CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0078-0464-61</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0078-0464-61</Value></Pair><Pair><Name>TradeName</Name><Value>AREDIA FOR INJECTION</Value></Pair><Pair><Name>FirmName</Name><Value>NOVARTIS PHARMACEUTICALS CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0378-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0378-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0456-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0456-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>ARMOUR THYROID TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>FOREST PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0472-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0472-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>BENZOYL PEROXIDE PADS</Value></Pair><Pair><Name>FirmName</Name><Value>ACTAVIS MID ATLANTIC LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0472-0464-30</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0472-0464-30</Value></Pair><Pair><Name>TradeName</Name><Value>BENZOYL PEROXIDE PADS</Value></Pair><Pair><Name>FirmName</Name><Value>ACTAVIS MID ATLANTIC LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0472-0464-60</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0472-0464-60</Value></Pair><Pair><Name>TradeName</Name><Value>BENZOYL PEROXIDE PADS</Value></Pair><Pair><Name>FirmName</Name><Value>ACTAVIS MID ATLANTIC LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>10267-0464-0</Key><ResultSet><Pair><Name>NDCCode</Name><Value>10267-0464-0</Value></Pair><Pair><Name>TradeName</Name><Value>FEROTRINSIC CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>CONTRACT PHARMACAL CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>10267-0464-1</Key><ResultSet><Pair><Name>NDCCode</Name><Value>10267-0464-1</Value></Pair><Pair><Name>TradeName</Name><Value>FEROTRINSIC CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>CONTRACT PHARMACAL CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>10267-0464-4</Key><ResultSet><Pair><Name>NDCCode</Name><Value>10267-0464-4</Value></Pair><Pair><Name>TradeName</Name><Value>FEROTRINSIC CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>CONTRACT PHARMACAL CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>13411-464-04</Key><ResultSet><Pair><Name>NDCCode</Name><Value>13411-464-04</Value></Pair><Pair><Name>TradeName</Name><Value>ERYTHROCIN STEARATE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>ADVANCED PHARMACEUTICAL SERVICES INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>14049-464-34</Key><ResultSet><Pair><Name>NDCCode</Name><Value>14049-464-34</Value></Pair><Pair><Name>TradeName</Name><Value>NEOMYCIN AND POLYMYXIN B SULFATES AND BACITRACIN OPH OINTMENT</Value></Pair><Pair><Name>FirmName</Name><Value>RX VETERINARY PRODUCTS</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>21695-464-07</Key><ResultSet><Pair><Name>NDCCode</Name><Value>21695-464-07</Value></Pair><Pair><Name>TradeName</Name><Value>LEVAQUIN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>REBEL DISTRIBUTORS CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>33261-464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>33261-464-01</Value></Pair><Pair><Name>TradeName</Name><Value>AMOXICILLIN CLAVULANATE POTASSIUM SUSPENSION</Value></Pair><Pair><Name>FirmName</Name><Value>AIDAREX PHARMACUTICALS LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>33358-464-30</Key><ResultSet><Pair><Name>NDCCode</Name><Value>33358-464-30</Value></Pair><Pair><Name>TradeName</Name><Value>BENAZEPRIL HYDROCHLORIDE AND HYDROCHLOROTHIAZIDE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>CORE PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>43353-464-32</Key><ResultSet><Pair><Name>NDCCode</Name><Value>43353-464-32</Value></Pair><Pair><Name>TradeName</Name><Value>RISPERIDONE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>DBA PREPAK SYSTEMS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>49288-0464-1</Key><ResultSet><Pair><Name>NDCCode</Name><Value>49288-0464-1</Value></Pair><Pair><Name>TradeName</Name><Value>SPONDYLOCLADIUM INJECTION SOLUTION</Value></Pair><Pair><Name>FirmName</Name><Value>ANTIGEN LABORATORIES INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>49288-0464-2</Key><ResultSet><Pair><Name>NDCCode</Name><Value>49288-0464-2</Value></Pair><Pair><Name>TradeName</Name><Value>SPONDYLOCLADIUM INJECTION SOLUTION</Value></Pair><Pair><Name>FirmName</Name><Value>ANTIGEN LABORATORIES INC</Value></Pair></ResultSet></WebServiceResult></QueryResult></QueryResponse></soap:Body></soap:Envelope>
0
blue44
Asked:
blue44
  • 5
  • 4
  • 3
1 Solution
 
Brijesh ChauhanStaff IT EngineerCommented:
Just Use XMLPARSE function, this will return you  a structure..

<cfprocessingdirective suppresswhitespace="yes">
<cfsavecontent variable="soap"> 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://YourWDSLHere.com/webservice/2008" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<SOAP-ENV:Body>
<tns:Query xmlns:tns="http://YourWDSLHere.com/webservice/2008">
<tns:Type>NDC</tns:Type>
<tns:QueryString>00006-0464-05</tns:QueryString>
<tns:Token>YourTokenHere</tns:Token>
</tns:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</cfsavecontent>

<cfhttp url="http://www.YourWDSLHere.com/wspHVLookup.asmx" method="post" proxyserver="indiaproxy.india.cypress.com" proxyport="8080">
&#9; <cfhttpparam type="header" name="content-type" value="text/xml"> 
    <cfhttpparam type="header" name="SOAPAction" value="http://YourWDSLHere.com/webservice/2008/Query"> 
    <cfhttpparam type="header" name="content-length" value="#len(soap)#"> 
    <cfhttpparam type="header" name="charset" value="utf-8"> 
    <cfhttpparam type="xml" name="message" value="#trim(soap)#">  
</cfhttp>
<cfset response = XMLParse(trim(cfhttp.FileContent)) >
<cfdump var="#response#">
</cfprocessingdirective>

Open in new window

0
 
Brijesh ChauhanStaff IT EngineerCommented:
You can get the results in an ARRAY... here is how you do it.. use XMLSEARCH for the webServiceResult...
<cfprocessingdirective suppresswhitespace="yes">
<cfsavecontent variable="soap"> 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://YourWDSLHere.com/webservice/2008" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<SOAP-ENV:Body>
<tns:Query xmlns:tns="http://YourWDSLHere.com/webservice/2008">
<tns:Type>NDC</tns:Type>
<tns:QueryString>00006-0464-05</tns:QueryString>
<tns:Token>YourTokenHere</tns:Token>
</tns:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</cfsavecontent>

<cfhttp url="http://www.YourWDSLHere.com/wspHVLookup.asmx" method="post" proxyserver="indiaproxy.india.cypress.com" proxyport="8080">
&#9; <cfhttpparam type="header" name="content-type" value="text/xml"> 
    <cfhttpparam type="header" name="SOAPAction" value="http://YourWDSLHere.com/webservice/2008/Query"> 
    <cfhttpparam type="header" name="content-length" value="#len(soap)#"> 
    <cfhttpparam type="header" name="charset" value="utf-8"> 
    <cfhttpparam type="xml" name="message" value="#trim(soap)#">  
</cfhttp>
<cfset response = XMLParse(trim(cfhttp.FileContent)) >
<cfset responseNodes = xmlSearch(
response,
"//*[ local-name() = 'WebServiceResult' ]"
) />
<cfdump var="#responseNodes#">
</cfprocessingdirective>

Open in new window

0
 
blue44Author Commented:
Thanks for responding again to my post :-)

Assigning it to an array really helps.  After reviewing the array output, how would you reference the individual XML elements...specifically the name/value pairs?
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
Brijesh ChauhanStaff IT EngineerCommented:
A little bit involved, but you can parse as below..

<cfprocessingdirective suppresswhitespace="yes">
<cfsavecontent variable="soap"> 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://YourWDSLHere.com/webservice/2008" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<SOAP-ENV:Body>
<tns:Query xmlns:tns="http://YourWDSLHere.com/webservice/2008">
<tns:Type>NDC</tns:Type>
<tns:QueryString>00006-0464-05</tns:QueryString>
<tns:Token>YourTokenHere</tns:Token>
</tns:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</cfsavecontent>

<cfhttp url="http://www.YourWDSLHere.com/wspHVLookup.asmx" method="post" proxyserver="indiaproxy.india.cypress.com" proxyport="8080">
&#9; <cfhttpparam type="header" name="content-type" value="text/xml"> 
    <cfhttpparam type="header" name="SOAPAction" value="http://YourWDSLHere.com/webservice/2008/Query"> 
    <cfhttpparam type="header" name="content-length" value="#len(soap)#"> 
    <cfhttpparam type="header" name="charset" value="utf-8"> 
    <cfhttpparam type="xml" name="message" value="#trim(soap)#">  
</cfhttp>
<cfset response = XMLParse(trim(cfhttp.FileContent)) >
<cfset responseNodes = xmlSearch(
response,
"//*[ local-name() = 'WebServiceResult' ]"
) />
<cfloop from="1" to="#ArrayLen(responseNodes)#" index="i">
<cfset responseNodesArr = responseNodes[i].XmlChildren >
<cfset responseNodesArrTemp = responseNodesArr[3].XmlChildren >
<cfset responseNodesArrTempNew = responseNodesArrTemp[1].XmlChildren >
<cfset name = responseNodesArrTempNew[1].XmlText>
<cfset value =  responseNodesArrTempNew[2].XmlText >
<cfdump var="#name#">
<cfdump var="#value#">
<br/>
</cfloop>
</cfprocessingdirective>

Open in new window

0
 
Brijesh ChauhanStaff IT EngineerCommented:
here this gives you the complete results...

<cfprocessingdirective suppresswhitespace="yes">
<cfsavecontent variable="soap"> 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://YourWDSLHere.com/webservice/2008" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<SOAP-ENV:Body>
<tns:Query xmlns:tns="http://YourWDSLHere.com/webservice/2008">
<tns:Type>NDC</tns:Type>
<tns:QueryString>00006-0464-05</tns:QueryString>
<tns:Token>YourTokenHere</tns:Token>
</tns:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</cfsavecontent>

<cfhttp url="http://www.YourWDSLHere.com/wspHVLookup.asmx" method="post" proxyserver="indiaproxy.india.cypress.com" proxyport="8080">
&#9; <cfhttpparam type="header" name="content-type" value="text/xml"> 
    <cfhttpparam type="header" name="SOAPAction" value="http://YourWDSLHere.com/webservice/2008/Query"> 
    <cfhttpparam type="header" name="content-length" value="#len(soap)#"> 
    <cfhttpparam type="header" name="charset" value="utf-8"> 
    <cfhttpparam type="xml" name="message" value="#trim(soap)#">  
</cfhttp>
<cfset response = cfhttp.FileContent >
<cfset response = response.ReplaceAll("(</?)(\w+:)","$1") >
<cfset response = response.ReplaceAll("xmlns(:\w+)?=""[^""]*""","") >
<cfset response = XMLParse(trim(response)) >
<cfset responseNodes = xmlSearch(response,"//*[ local-name() = 'WebServiceResult' ]") >
<cfloop from="1" to="#ArrayLen(responseNodes)#" index="i">
<cfset responseNodesArr = responseNodes[i].XmlChildren >
<cfset responseNodesArrTemp = responseNodesArr[3].XmlChildren >
<cfloop from="1" to="3" index="y">
<cfset responseNodesArrTempNew = responseNodesArrTemp[y].XmlChildren >
<cfset name = responseNodesArrTempNew[1].XmlText>
<cfset value =  responseNodesArrTempNew[2].XmlText >
<cfdump var="#name#">
<cfdump var="#value#">
<br/>
</cfloop>
<br/>
</cfloop>
</cfprocessingdirective>

Open in new window



RESULTS ->


NDCCode 0006-0464-01
TradeName EMEND CAPSULES
FirmName MERCK AND CO INC

NDCCode 0006-0464-05
TradeName EMEND CAPSULES
FirmName MERCK AND CO INC

NDCCode 0006-0464-10
TradeName EMEND CAPSULES
FirmName MERCK AND CO INC

NDCCode 49288-0464-5
TradeName SPONDYLOCLADIUM INJECTION SOLUTION
FirmName ANTIGEN LABORATORIES INC

NDCCode 53746-464-01
TradeName IBUPROFEN TABLETS
FirmName AMNEAL PHARMACEUTICALS NY LLC

NDCCode 53746-464-05
TradeName IBUPROFEN TABLETS
FirmName AMNEAL PHARMACEUTICALS NY LLC

NDCCode 53746-464-30
TradeName IBUPROFEN TABLETS
FirmName AMNEAL PHARMACEUTICALS NY LLC

NDCCode 53746-464-60
TradeName IBUPROFEN TABLETS
FirmName AMNEAL PHARMACEUTICALS NY LLC

NDCCode 53746-464-90
TradeName IBUPROFEN TABLETS
FirmName AMNEAL PHARMACEUTICALS NY LLC

NDCCode 62794-464-01
TradeName MAXZIDE .25 MG TABLETS
FirmName MYLAN BERTEK PHARMACEUTICALS INC

NDCCode 62794-464-05
TradeName MAXZIDE .25 MG TABLETS
FirmName MYLAN BERTEK PHARMACEUTICALS INC

NDCCode 62794-464-88
TradeName MAXZIDE .25 MG TABLETS
FirmName MYLAN BERTEK PHARMACEUTICALS INC

NDCCode 63739-464-05
TradeName FUROSEMIDE INJECTION
FirmName MCKESSON PACKAGING SERVICES BUSINESS UNIT MCKESSON CORP

NDCCode 0078-0464-61
TradeName AREDIA FOR INJECTION
FirmName NOVARTIS PHARMACEUTICALS CORP

NDCCode 0378-0464-01
TradeName MAXZIDE TABLETS
FirmName MYLAN PHARMACEUTICALS INC

NDCCode 0456-0464-01
TradeName ARMOUR THYROID TABLETS
FirmName FOREST PHARMACEUTICALS INC

NDCCode 0472-0464-01
TradeName BENZOYL PEROXIDE PADS
FirmName ACTAVIS MID ATLANTIC LLC

NDCCode 0472-0464-30
TradeName BENZOYL PEROXIDE PADS
FirmName ACTAVIS MID ATLANTIC LLC

NDCCode 0472-0464-60
TradeName BENZOYL PEROXIDE PADS
FirmName ACTAVIS MID ATLANTIC LLC

NDCCode 10267-0464-0
TradeName FEROTRINSIC CAPSULES
FirmName CONTRACT PHARMACAL CORP

NDCCode 10267-0464-1
TradeName FEROTRINSIC CAPSULES
FirmName CONTRACT PHARMACAL CORP

NDCCode 10267-0464-4
TradeName FEROTRINSIC CAPSULES
FirmName CONTRACT PHARMACAL CORP

NDCCode 13411-464-04
TradeName ERYTHROCIN STEARATE TABLETS
FirmName ADVANCED PHARMACEUTICAL SERVICES INC

NDCCode 14049-464-34
TradeName NEOMYCIN AND POLYMYXIN B SULFATES AND BACITRACIN OPH OINTMENT
FirmName RX VETERINARY PRODUCTS

NDCCode 21695-464-07
TradeName LEVAQUIN TABLETS
FirmName REBEL DISTRIBUTORS CORP

NDCCode 33261-464-01
TradeName AMOXICILLIN CLAVULANATE POTASSIUM SUSPENSION
FirmName AIDAREX PHARMACUTICALS LLC

NDCCode 33358-464-30
TradeName BENAZEPRIL HYDROCHLORIDE AND HYDROCHLOROTHIAZIDE TABLETS
FirmName CORE PHARMACEUTICALS INC

NDCCode 43353-464-32
TradeName RISPERIDONE TABLETS
FirmName DBA PREPAK SYSTEMS INC

NDCCode 49288-0464-1
TradeName SPONDYLOCLADIUM INJECTION SOLUTION
FirmName ANTIGEN LABORATORIES INC

NDCCode 49288-0464-2
TradeName SPONDYLOCLADIUM INJECTION SOLUTION
FirmName ANTIGEN LABORATORIES INC
0
 
_agx_Commented:
specifically the name/value pairs?

Extracting name/value is even simpler than that using local-name

<cfset doc  = XmlParse(trim(cfhttp.FileContent)))>
<cfset data = XMLSearch(doc, "//*[ local-name() = 'Pair' ]")>
<cfloop array="#data#" index="pair">
   <cfoutput>
    Name: #pair.name.xmlText# Value: #pair.value.xmlText#<br>
   </cfoutput>
</cfloop>

Open in new window

0
 
blue44Author Commented:
@brijeshchauhan: Sorry for the delay in getting back to you.  Your solution worked great!! Thanks so much.

@aqx: Very cool code snippet but it only received two of the three name/value pairs
0
 
_agx_Commented:
@blue44 - Nope, using the SOAP sample in your first post gives the full results below (CF8&CF9).  
Are you sure you implemented it correctly?

Results
Name: NDCCode Value: 0006-0464-01
Name: TradeName Value: EMEND CAPSULES
Name: FirmName Value: MERCK AND CO INC
Name: NDCCode Value: 0006-0464-05
Name: TradeName Value: EMEND CAPSULES
Name: FirmName Value: MERCK AND CO INC
Name: NDCCode Value: 0006-0464-10
Name: TradeName Value: EMEND CAPSULES
Name: FirmName Value: MERCK AND CO INC
Name: NDCCode Value: 49288-0464-5
Name: TradeName Value: SPONDYLOCLADIUM INJECTION SOLUTION
Name: FirmName Value: ANTIGEN LABORATORIES INC
Name: NDCCode Value: 53746-464-01
Name: TradeName Value: IBUPROFEN TABLETS
Name: FirmName Value: AMNEAL PHARMACEUTICALS NY LLC
Name: NDCCode Value: 53746-464-05
Name: TradeName Value: IBUPROFEN TABLETS
Name: FirmName Value: AMNEAL PHARMACEUTICALS NY LLC
Name: NDCCode Value: 53746-464-30
Name: TradeName Value: IBUPROFEN TABLETS
Name: FirmName Value: AMNEAL PHARMACEUTICALS NY LLC
Name: NDCCode Value: 53746-464-60
Name: TradeName Value: IBUPROFEN TABLETS
Name: FirmName Value: AMNEAL PHARMACEUTICALS NY LLC
Name: NDCCode Value: 53746-464-90
Name: TradeName Value: IBUPROFEN TABLETS
Name: FirmName Value: AMNEAL PHARMACEUTICALS NY LLC
Name: NDCCode Value: 62794-464-01
Name: TradeName Value: MAXZIDE .25 MG TABLETS
Name: FirmName Value: MYLAN BERTEK PHARMACEUTICALS INC
Name: NDCCode Value: 62794-464-05
Name: TradeName Value: MAXZIDE .25 MG TABLETS
Name: FirmName Value: MYLAN BERTEK PHARMACEUTICALS INC
Name: NDCCode Value: 62794-464-88
Name: TradeName Value: MAXZIDE .25 MG TABLETS
Name: FirmName Value: MYLAN BERTEK PHARMACEUTICALS INC
Name: NDCCode Value: 63739-464-05
Name: TradeName Value: FUROSEMIDE INJECTION
Name: FirmName Value: MCKESSON PACKAGING SERVICES BUSINESS UNIT MCKESSON CORP
Name: NDCCode Value: 0078-0464-61
Name: TradeName Value: AREDIA FOR INJECTION
Name: FirmName Value: NOVARTIS PHARMACEUTICALS CORP
Name: NDCCode Value: 0378-0464-01
Name: TradeName Value: MAXZIDE TABLETS
Name: FirmName Value: MYLAN PHARMACEUTICALS INC
Name: NDCCode Value: 0456-0464-01
Name: TradeName Value: ARMOUR THYROID TABLETS
Name: FirmName Value: FOREST PHARMACEUTICALS INC
Name: NDCCode Value: 0472-0464-01
Name: TradeName Value: BENZOYL PEROXIDE PADS
Name: FirmName Value: ACTAVIS MID ATLANTIC LLC
Name: NDCCode Value: 0472-0464-30
Name: TradeName Value: BENZOYL PEROXIDE PADS
Name: FirmName Value: ACTAVIS MID ATLANTIC LLC
Name: NDCCode Value: 0472-0464-60
Name: TradeName Value: BENZOYL PEROXIDE PADS
Name: FirmName Value: ACTAVIS MID ATLANTIC LLC
Name: NDCCode Value: 10267-0464-0
Name: TradeName Value: FEROTRINSIC CAPSULES
Name: FirmName Value: CONTRACT PHARMACAL CORP
Name: NDCCode Value: 10267-0464-1
Name: TradeName Value: FEROTRINSIC CAPSULES
Name: FirmName Value: CONTRACT PHARMACAL CORP
Name: NDCCode Value: 10267-0464-4
Name: TradeName Value: FEROTRINSIC CAPSULES
Name: FirmName Value: CONTRACT PHARMACAL CORP
Name: NDCCode Value: 13411-464-04
Name: TradeName Value: ERYTHROCIN STEARATE TABLETS
Name: FirmName Value: ADVANCED PHARMACEUTICAL SERVICES INC
Name: NDCCode Value: 14049-464-34
Name: TradeName Value: NEOMYCIN AND POLYMYXIN B SULFATES AND BACITRACIN OPH OINTMENT
Name: FirmName Value: RX VETERINARY PRODUCTS
Name: NDCCode Value: 21695-464-07
Name: TradeName Value: LEVAQUIN TABLETS
Name: FirmName Value: REBEL DISTRIBUTORS CORP
Name: NDCCode Value: 33261-464-01
Name: TradeName Value: AMOXICILLIN CLAVULANATE POTASSIUM SUSPENSION
Name: FirmName Value: AIDAREX PHARMACUTICALS LLC
Name: NDCCode Value: 33358-464-30
Name: TradeName Value: BENAZEPRIL HYDROCHLORIDE AND HYDROCHLOROTHIAZIDE TABLETS
Name: FirmName Value: CORE PHARMACEUTICALS INC
Name: NDCCode Value: 43353-464-32
Name: TradeName Value: RISPERIDONE TABLETS
Name: FirmName Value: DBA PREPAK SYSTEMS INC
Name: NDCCode Value: 49288-0464-1
Name: TradeName Value: SPONDYLOCLADIUM INJECTION SOLUTION
Name: FirmName Value: ANTIGEN LABORATORIES INC
Name: NDCCode Value: 49288-0464-2
Name: TradeName Value: SPONDYLOCLADIUM INJECTION SOLUTION
Name: FirmName Value: ANTIGEN LABORATORIES INC
0
 
_agx_Commented:
<cfset response = cfhttp.FileContent >
<cfset response = response.ReplaceAll("(</?)(\w+:)","$1") >
<cfset response = response.ReplaceAll("xmlns(:\w+)?=""[^""]*""","") >


For more information, the source of that code is:
http://www.bennadel.com/blog/494-Stripping-XML-Name-Spaces-And-Node-Prefixes-From-ColdFusion-XML-Data-To-Simplify-XPath-.htm
0
 
_agx_Commented:
Another unanswered question for the archives ...
0
 
blue44Author Commented:
@aqx: Thanks...you might be right and I was coding late that night.  Bottom line, I appreciate everyone's continued assistance on EE -- what a great service...especially for developers like myself who don't work in large development teams where you can bounce issues off each other.
0
 
_agx_Commented:
@blue44 - I hear ya'.  I just wanted to point out the extra code shouldn't be needed.  The point of using local-name() is to ignore the namespace. So removing the namespace and *also* use local-name() doesn't really make sense.  You normally use one or the other - not both.  But glad you got it solved .. and thanks for following up :)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now