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:
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?
<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>
Solved! Go to Solution.
Hi @moutinhoabreu,
You could use the following expression:
xpath(xml(outputs('Compose')),'string(/*[name()="ns:StockFile"]/*[name()="ns:StockHeader"]/*[name()="ns:EndDate"])')
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.
Hi @moutinhoabreu,
You could use the following expression:
xpath(xml(outputs('Compose')),'string(/*[name()="ns:StockFile"]/*[name()="ns:StockHeader"]/*[name()="ns:EndDate"])')
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.
Here is the document about xpath() function:
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
User | Count |
---|---|
90 | |
41 | |
22 | |
20 | |
16 |
User | Count |
---|---|
134 | |
53 | |
47 | |
36 | |
25 |