Link to home
Start Free TrialLog in
Avatar of cottyengland
cottyengland

asked on

Title: CFMX 7 converting XML input stream to query object

How can I convert this into a query object?

                  <ActiveContracts Contract="SP010000D0347" DeliveryOrder="0126" CLIN="0034AA" Qty="144" UnitOfIssue="PR" NSN="8405010760772" DeliveryDate="" ProjectCode="" Requisition="              " RequisitionSuffix="" ShipToDoDAAC="UY3246" DistrCode="" PriorityCode="" AwardDate="01/01/2003" FastPayCode="N" AdminOffice="S0701A" UnitPrice="12.00000" QtyVarianceAllowed=".00000" InspectionPoint="S" AcceptancePoint="S" FOBPoint="D" DiscountCode="0000" PayOffice="SC0100" GFMUnitPrice=".00000" BailmentCode="" BuyerName="" BuyerPhone="" BuyerEmail="" CaseLotQty="12"/>

Thank You
Avatar of DanielSKim
DanielSKim

is this what you are looking for?

<cfset xmlString = '<ActiveContracts Contract="SP010000D0347" DeliveryOrder="0126" CLIN="0034AA" Qty="144" UnitOfIssue="PR" NSN="8405010760772" DeliveryDate="" ProjectCode="" Requisition="              " RequisitionSuffix="" ShipToDoDAAC="UY3246" DistrCode="" PriorityCode="" AwardDate="01/01/2003" FastPayCode="N" AdminOffice="S0701A" UnitPrice="12.00000" QtyVarianceAllowed=".00000" InspectionPoint="S" AcceptancePoint="S" FOBPoint="D" DiscountCode="0000" PayOffice="SC0100" GFMUnitPrice=".00000" BailmentCode="" BuyerName="" BuyerPhone="" BuyerEmail="" CaseLotQty="12"/>' />

<cfset myXmlAttributes = xmlParse(xmlString).xmlRoot.xmlAttributes />
<cfset myQueryObject = QueryNew(StructKeyList(myXmlAttributes)) />
<cfset QueryAddRow(myQueryObject) />

<cfloop collection="#myXmlAttributes#" item="a">
      <cfset QuerySetCell(myQueryObject, a, myXmlAttributes[a]) />
</cfloop>
Avatar of cottyengland

ASKER

YEs it is but how do I parse more than 1 record.. for example

<ActiveContracts Contract="SP010000D0347" DeliveryOrder="0126" CLIN="0034AA" Qty="144" UnitOfIssue="PR" NSN="8405010760772" DeliveryDate="" ProjectCode="" Requisition="              " RequisitionSuffix="" ShipToDoDAAC="UY3246" DistrCode="" PriorityCode="" AwardDate="01/01/2003" FastPayCode="N" AdminOffice="S0701A" UnitPrice="12.00000" QtyVarianceAllowed=".00000" InspectionPoint="S" AcceptancePoint="S" FOBPoint="D" DiscountCode="0000" PayOffice="SC0100" GFMUnitPrice=".00000" BailmentCode="" BuyerName="" BuyerPhone="" BuyerEmail="" CaseLotQty="12"/>
ActiveContracts Contract="SP010000D0347" DeliveryOrder="0126" CLIN="0034AA" Qty="144" UnitOfIssue="PR" NSN="8405010760772" DeliveryDate="" ProjectCode="" Requisition="              " RequisitionSuffix="" ShipToDoDAAC="UY3246" DistrCode="" PriorityCode="" AwardDate="01/01/2003" FastPayCode="N" AdminOffice="S0701A" UnitPrice="12.00000" QtyVarianceAllowed=".00000" InspectionPoint="S" AcceptancePoint="S" FOBPoint="D" DiscountCode="0000" PayOffice="SC0100" GFMUnitPrice=".00000" BailmentCode="" BuyerName="" BuyerPhone="" BuyerEmail="" CaseLotQty="12"/>

I see the cfloop collecting the data elements.... where or how would you use cfloop to loop through "ActiveContracts". I could have as many as 100 seperate "ActiveContracts" in an XML.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of DanielSKim
DanielSKim

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
You are very good. Thank You