function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sunny NarulaSunny Narula 

Parsing XML to extract multiple records and inserting that in DB

<DealItems>
  <DealItem>
    <Name>CRI-201503-0444533</Name>
    <CurrencyIsoCode>USD</CurrencyIsoCode>
    <RecordType />
    <Account_Name__c>Test XML Account</Account_Name__c>
    <Approval_Required__c>true</Approval_Required__c>
    <Approval_Status__c>Approved</Approval_Status__c>
    <fCalculatedAmount__c>55000</fCalculatedAmount__c>
    <Comments__c>Deal Type: Ongoing Template; Reason for Deal: Text XML Generating</Comments__c>
    <Issued_Date__c />
    <Amount__c>55000</ Amount__c>
    <Analyst1__c />
    < Dept_Comments__c />
    < Invoice_No__c>4580</ Invoice_No__c>
    < Issued_Status__c>Pending</ Issued_Status__c>
    < Memo_No__c>33</ Memo_No__c>
    <f Type__c>Ongoing Template</f Type__c>
    <Customer_Address__c />
    <Date_Approved__c>2015-03-12T00:00:00</Date_Approved__c>
    <Date_Received_at_Warehouse__c>2015-03-12T00:00:00</Date_Received_at_Warehouse__c>
    <District__c>467 - Great Lakes</District__c>
    <Documentation_Complete_Date__c>2015-03-12T00:00:00</Documentation_Complete_Date__c>
    <Documentation_Status__c>Incomplete</Documentation_Status__c>
    <Documentation_Verification__c>Complete</Documentation_Verification__c>
    <Effective_Period__c>2015-04-01T00:00:00</Effective_Period__c>
    <ERP_Sold_To__c />
    <Final_Amount__c>5500</Final_Amount__c>
    <HasAttachment__c>true</HasAttachment__c>
    <PO_No__c />
    <Product__c />
    <Quantity__c />
    <Rejection_Reason__c />
    <Stage__c />
    <UOM__c />
    <Upfront_Payment__c>false</Upfront_Payment__c>
    <Uploaded_By__c />
    <Verified_Sales_Distributor__c>567</Verified_Sales_Distributor__c>
  </DealItem>
 <DealItem>
    <Name>CRI-201503-0444534</Name>
    <CurrencyIsoCode>USD</CurrencyIsoCode>
    <RecordType />
    <Account_Name__c>Test XML Account123</Account_Name__c>
    <Approval_Required__c>false</Approval_Required__c>
    <Approval_Status__c>Rejected</Approval_Status__c>
    <fCalculatedAmount__c>75000</fCalculatedAmount__c>
    <Comments__c>Deal Type: Ongoing Template; </Comments__c>
    <Issued_Date__c />
    <Amount__c>75000</ Amount__c>
    <Analyst1__c />
    < Dept_Comments__c />
    < Invoice_No__c>4582</ Invoice_No__c>
    < Issued_Status__c>Rejected</ Issued_Status__c>
    < Memo_No__c>35</ Memo_No__c>
    <f Type__c>Upgoing Template</f Type__c>
    <Customer_Address__c />
    <Date_Approved__c>2015-03-14T00:00:00</Date_Approved__c>
    <Date_Received_at_Warehouse__c>2017-03-12T00:00:00</Date_Received_at_Warehouse__c>
    <District__c>468 - Great Lakes</District__c>
    <Documentation_Complete_Date__c>2018-03-12T00:00:00</Documentation_Complete_Date__c>
    <Documentation_Status__c>Complete</Documentation_Status__c>
    <Documentation_Verification__c>Complete</Documentation_Verification__c>
    <Effective_Period__c>2015-04-02T00:00:00</Effective_Period__c>
    <ERP_Sold_To__c />
    <Final_Amount__c>7500</Final_Amount__c>
    <HasAttachment__c>false</HasAttachment__c>
    <PO_No__c />
    <Product__c />
    <Quantity__c />
    <Rejection_Reason__c />
    <Stage__c />
    <UOM__c />
    <Upfront_Payment__c>false</Upfront_Payment__c>
    <Uploaded_By__c />
    <Verified_Sales_Distributor__c>561</Verified_Sales_Distributor__c>
  </DealItem>  
</DealItems>

 

I have above xml as a string to a ApexWebService called from an external .Net application,
it will have N number of Deal Records (in above I have 2 deal record), 
I have a Deal object here in the ORG.
I need to take these record out from XML string and create new Deal records...

Requesting to please guide me the way to Parse is XML with N number of Deal records and make new Deal Object 
as we can create a List Collection of Deal and insert all records from XML to database....

I need help for Parsing this XML to get the Deal record.

thanks
Sunny