How to parse xml output from Http request in logicApp using xpath expression?

Harshitha KODA 1 Reputation point
2020-11-23T08:36:47.713+00:00

Below is my Xml body output,
Body:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<notifications xmlns="http://soap.sforce.com/2005/09/outbound">
<OrganizationId>00D2w000ghj72NEAT</OrganizationId>
<ActionId>04k2w0000004FdvAAE</ActionId>
<SessionId>00D2w00000DM72N!ARsfgG0PvTV4_PFOLH7FfAf0MScAJlVkK6mghdtryni5hmK9YuoZFS059bWbuDA060AnOqZ1hSWKQQYfghcb.3mHLG5l8X</SessionId>
<EnterpriseUrl>https://ap16.salesforce.com/services/Soap/c/50.0/00D2w00000Dfhy2N</EnterpriseUrl>
<PartnerUrl>https://ap16.salesforce.com/services/Soap/u/50.0/00D2w00000Dyh72N</PartnerUrl>
<Notification>
<Id>04l2w0000005fyhjAAI</Id>
<sObject xsi:type="sf:Case" xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
<sf:Id>5002w00000BSfffAA1</sf:Id>
<sf:CaseNumber>000007551</sf:CaseNumber>
<sf:ContactEmail>gdfgothers@Stuff .com</sf:ContactEmail>
<sf:ContactId>056632w0000fyhjntHAA3</sf:ContactId>
<sf:ContactPhone>0999155r475</sf:ContactPhone>
<sf:CreatedById>0052w00000fhzLcAAI</sf:CreatedById>
<sf:CreatedDate>2020-11-23T07:36:08.000Z</sf:CreatedDate>
<sf:IsClosed>false</sf:IsClosed>
<sf:IsDeleted>false</sf:IsDeleted>
<sf:IsEscalated>false</sf:IsEscalated>
<sf:LastModifiedById>0052w0000g6likuzLcAAI</sf:LastModifiedById>
<sf:LastModifiedDate>2020-11-23T07:37:22.000Z</sf:LastModifiedDate>
<sf:LastReferencedDate>2020-11-23T07:37:22.000Z</sf:LastReferencedDate>
<sf:LastViewedDate>2020-11-23T07:37:22.000Z</sf:LastViewedDate>
<sf:Origin>Web</sf:Origin>
<sf:OwnerId>0052w00000hlzghAI</sf:OwnerId>
<sf:Priority>Medium</sf:Priority>
<sf:Status>New</sf:Status>
<sf:Subject>id check</sf:Subject>
<sf:SystemModstamp>2020-11-23T07:37:22.000Z</sf:SystemModstamp>
</sObject>
</Notification>
</notifications>
</soapenv:Body>
</soapenv:Envelope>

From the above XML output from Http request trigger body, i need to access these fields sf:Id, sf:CaseNumber , sf:CreatedById, sf:LastModifiedById , sf:Subject.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ChaitanyaNaykodi-MSFT 27,476 Reputation points Microsoft Employee Moderator
    2020-11-24T01:42:24.947+00:00

    Hello @Harshitha KODA , Thank you for reaching out. You can follow the solution mentioned in this thread which deals with the similar issue. Please let me know if you need any additional help.

    0 comments No comments

  2. Mayur Macwan 111 Reputation points
    2020-11-30T19:49:16.2+00:00

    Hi @Harshitha KODA

    Try below in the Expression.

    xpath(xml(base64ToBinary(triggerBody())),'string(/Envelope/Body/notifications/Notification/sObject/Id)')  
    

    or with a longer version of xpath like this

     xpath(xml(base64ToBinary(triggerBody())),'string(/*[local-name()=''Envelope'']/*[local-name()=''Body'']/*[local-name()=''notifications'']/*[local-name()=''Notification'']/*[local-name()=''sObject'']/*[local-name()=''Id''])')  
    

    Similarly you can extract values of other fields as well.

    HTH.
    Mayur

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.