+ Start a Discussion
Sidharth Panda 5Sidharth Panda 5 

Parse XML in APEX

Hi,

Can someone can tell how to parse the below XML in APEX using XmlStreamWriter?

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
</s:Envelope>

Thanks!!
 
Ajay Ghuge 6Ajay Ghuge 6
Hi Sidharth,

You can use XMLStreamReader class for this : 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_xml_XmlStream_reader.htm

Dummy Code : 
while(reader.hasNext()) {

if (reader.getEventType() == XmlTag.START_ELEMENT) { 
        if ('' == reader.getLocalName()){ 
        } 
    } 
reader.next(); 


Regards,
Ajay