[SalesForce] How to read XML data in salesforce

I get data in XML from a web service from a connector URL, the xml contains data about people, now I have to read the names, emailids from that xml and compare with my org's contacts and so some operations. So how do I read it?

Best Answer

You need either Dom or XmlStreamReader class to parse your xml response. You can find sample code in the below links.

Xml parsing using XmlStreamReader:- https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_xml_streaming_reading.htm

Xml parsing using Dom:- https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_xml_dom.htm

Related Topic