cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
moutinhoabreu
Advocate IV
Advocate IV

parse xml file from sharepoint library

Hi Community,

 

For every XML file saved in a specific sharepoint folder location,  i need to parse it with power automate and retrieve the date from XML Header. (Please check the xml example below, i need to pull EndDate fields.)

This is the sequence of my flow:

 

Screenshot 2021-03-02 at 00.17.31.png

 

 

I've tried to fetch data with Xpath but always returned a null result.

 

xpath(xml(outputs('XML')), 'EndDate')

 

 

 

 

 

Though it was something related with fetching on xml header, so i've made some tests to get info from the nodes, but also got a null result:

 

xpath(xml(outputs('XML')), '//ProductCode')

 

 

What can i be doing wrong?

 

The XML file example:

 

<ns:StockFile xmlns:ns="urn:StockFile:PT_1_02" xmlns:doc="urn:schemas-basda-org:schema-extensions:documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns:StockHeader>
<ns:FileVersion>1_02</ns:FileVersion>
<ns:TaxRegistrationNumber>00000000</ns:TaxRegistrationNumber>
<ns:FiscalYear>2020</ns:FiscalYear>
<ns:EndDate>2020-12-31</ns:EndDate>
<ns:NoStock>false</ns:NoStock>
</ns:StockHeader>
<ns:Stock>
<ns:ProductCategory>M</ns:ProductCategory>
<ns:ProductCode>341252452345</ns:ProductCode>
<ns:ProductDescription>Care Kit Tube</ns:ProductDescription>
<ns:ProductNumberCode>660042376824</ns:ProductNumberCode>
<ns:ClosingStockQuantity>188.0</ns:ClosingStockQuantity>
<ns:UnitOfMeasure>Un</ns:UnitOfMeasure>
<ns:ClosingStockValue>2133.48</ns:ClosingStockValue>
</ns:Stock>
<ns:Stock>
<ns:ProductCategory>M</ns:ProductCategory>
<ns:ProductCode>09003NAVFW16</ns:ProductCode>
<ns:ProductDescription>DEE NAVY</ns:ProductDescription>
<ns:ProductNumberCode>09003NAVFW16</ns:ProductNumberCode>
<ns:ClosingStockQuantity>1.0</ns:ClosingStockQuantity>
<ns:UnitOfMeasure>Un</ns:UnitOfMeasure>
<ns:ClosingStockValue>18.65</ns:ClosingStockValue>
</ns:Stock>

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @moutinhoabreu,

 

You could use the following expression:

xpath(xml(outputs('Compose')),'string(/*[name()="ns:StockFile"]/*[name()="ns:StockHeader"]/*[name()="ns:EndDate"])')

Screenshot 2021-03-03 143141.jpg

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-litu-msft
Community Support
Community Support

Hi @moutinhoabreu,

 

You could use the following expression:

xpath(xml(outputs('Compose')),'string(/*[name()="ns:StockFile"]/*[name()="ns:StockHeader"]/*[name()="ns:EndDate"])')

Screenshot 2021-03-03 143141.jpg

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

v-litu-msft
Community Support
Community Support

Here is the document about xpath() function:

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

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the reply!

I was aware of this document and I've tried using this expression:

xpath(xml(outputs('XML')), 'Stock/FiscalYear')

 

outputs('XML') is previous compose step where I've placed the content of the file from get file content.

 

I get an empty input and empty output

Thanks

 

 

 

 

 

Helpful resources

Announcements
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

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (24,902)