web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Trouble while parsing ...
Power Automate
Answered

Trouble while parsing xml in logic apps. Flow reads xml from blob and writes to DB

(0) ShareShare
ReportReport
Posted on by 11

Hi All,

 

Following is the xml that I facing trouble with :

 

<?xml version="1.0" encoding="utf-16"?>

<ItemNotification>
        <MessageHeader>
             <MessageID>PABG0103329120200130120241</MessageID>
        </MessageHeader>
        <ItemList>
           <Item>
               <PartNumber>BG01033291</PartNumber>
               <AfterMarketClass/>
              <ApproverDate>2018-11-08</ApproverDate>
         </Item>
      </ItemList>
</ItemNotification>

 

I have tried the following xpath for parsing:

xpath(xml(string(body('Get_blob_content_using_path'))),'string(/ItemNotification/ItemList/Item/PartNumber/text()')

xpath(xml(string(body('Get_blob_content_using_path'))),'string(//PartNumber/text()')

 

I need the Text in PartNumber node. Also tried de-batching this in a For Each loop (not required but tried it). 

 

Following is my flow:

image.png

 

 

 

 

 

 

 

 

 

 

Categories:
  • Verified answer
    abm abm Profile Picture
    33,004 Most Valuable Professional on at

    Hi @Suhasuser 

     

    XPath expression failed to parse XML for UTF-16  so I did changed the first line of your XML to

     

    <?xml version="1.0" encoding="utf-8"?>

     

    or 

     

    <?xml version="1.0"?>

     

    Try the following steps:

     

    image.png

     

    Below is the expression I used.

    xpath(xml(outputs('Compose_2')),'//ItemList/Item/PartNumber/text()')
     
    image.png
     
     
     
  • Suhasuser Profile Picture
    11 on at

    Yes, that was the kink giving me the error. Problem solved. Thanks to you.

  • Suhasuser Profile Picture
    11 on at

    How to deal with this problem. I keep getting this xml from upstream how do read this using xpath in logic app if all xmls are utf-16  encoded ? Can you please give some suggestions ?

  • abm abm Profile Picture
    33,004 Most Valuable Professional on at

    Hi @Suhasuser 

     

    Thanks for the update. 

     

    You could use a replace expression to change the XML UTF value.

     

    Thanks

  • Suhasuser Profile Picture
    11 on at

    Hi ,

     

    I have used the following expression to replace the string from utf-16 to utf-8 :

    replace(string(triggerBody()?['Path']),'utf-16','utf-8')
     
    But it has not replaced as i can see in the output
     
    image.png
  • Verified answer
    abm abm Profile Picture
    33,004 Most Valuable Professional on at

    Hi @Suhasuser 

     

    Create a compose and map the XML.

     

    Next add another compose to use the replace.

     

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 445

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 300

Last 30 days Overall leaderboard