+ Start a Discussion
SFDC developer55SFDC developer55 

Parse Rest API response

Hi All,

Any idea how can I parse the below Rest API response using Apex code and how can I display this pageblock section.

<bns:QueryResult xmlns:bns="http://api.platform.boomi.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfResults="3">
<bns:result xsi:type="bns:Process" id="XXXXXX" name="AAA"/>
<bns:result xsi:type="bns:Process" id="XXXXXXXX" name="BBBB"/>
<bns:result xsi:type="bns:Process" id="XXXXXX" name="CCC"/>
</bns:QueryResult>

Regards,
PR
Best Answer chosen by SFDC developer55
SFDC developer55SFDC developer55
I am able to do that using the below code:
            if(response!=null && response.getBody()!=null) 
             {
                body=response.getBody();
                dom=new XMLDom(body);            
                //for( xmldom.element f: dom.getElementsByTagName('getProcessResponse'))
                
                for( xmldom.element f: dom.getElementsByTagName('QueryResult'))
                {
                    List<string> ids= New List <string> (); 
                    system.debug('here--> dom QueryResult=='+dom.getElementsByTagName('QueryResult'));
                    for( xmldom.element e: dom.getElementsByTagName('result'))
                    {                    
                        system.debug('here 2--> dom Result=='+dom.getElementsByTagName('result'));
                        system.debug('here 3-->  acc.name=='+ (String)e.getAttribute('name'));
                         system.debug('here 3-->  acc.id=='+ (String)e.getAttribute('id'));