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
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