cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
famcanico10
Regular Visitor

Parsing XML with xpath using dynamic XML string

Hi,

I'm trying to parse an XML string value from the "text" field under "post" entity in Dynamics 365.

Here's is the sample value of the field:

 

"<?xml version="1.0" encoding="utf-16"?><pi id="Account.Create.Post" icon="0" ya="1"><ps><p type="1" otc="8" id="ff87e0f2-813f-eb11-bf68-000d3a3abbc3">David So</p></ps></pi>"

 

I'm assigning that value to a Compose step then uses another Compose (Compose 2) step to parse it using xpath

compose_2.PNG

I am trying to get the string value, David So, of the p node but I'm getting this error:

error.PNG

 

is there anything wrong with the syntax of the expression I'm using? 

I'd appreciate any feedback on this. thank you.

2 REPLIES 2
jinivthakkar
Resident Rockstar
Resident Rockstar

@famcanico10 I was able to extract the information you need.

 

jinivthakkar_0-1612350968986.png

xpath(xml(outputs('Compose')),'string(//p)')

Output :

jinivthakkar_1-1612351035487.png

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

jinivthakkar
Resident Rockstar
Resident Rockstar

@famcanico10 I am also facing same issue with <?xml version="1.0" encoding="utf-16"?> but if I change it to <?xml version="1.0" encoding="utf-8"?> it just works fine. So it looks some issue with the encoding tag if possible change it to utf-8 and try and it should work.

 

I could not find any example of documentation where utf-16 was used or demonstrated, but feel free to go through below links and confirm again.

 

More details about Xpath function, please check the following article:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#x...

 

More details about Xpath examples, please check the following article:

https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,260)