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
Poorna DeveloperPoorna Developer 

Apex code to Upload/Insert xml file to salesforce object

Hi,

I need apex (xml) code to upload/Insert address fields in to  account or contact object in salesforce.

ie. in xml I have a code like '<name>Kirk Stevens</name>'+
'<street1>808 State St</street1>'+
'<street2>Apt. 2</street2>'+
'<city>Palookaville</city>'+
'<state>PA</state>'+
'<country>USA</country>'+

after debug this apex code, I want a address field with these address data in account or contact.

Is this possible?
Any help.
Thanks.
SwethaSwetha (Salesforce Developers) 
HI Poorna,
I see  you are trying to update the account/contact records from XML data.You will need to use Dom.XMLNode to parse through XML to fetch the elements . 
See below articles that explain this procedure.You will need to customize it according to your requirement.
https://developer.salesforce.com/forums/?id=9060G0000005sUkQAI
https://salesforce.stackexchange.com/questions/120687/how-to-create-records-from-xml-data

If this information helps, please mark this answer as best.