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

Parse XML to return first node

Any ideas on how to extract the first node or category of an XML file? I assume xpath is the way to go but not sure what to put in the expression:

 

For the example below, I wish to extract the value: ShipmentProfileReport

Possibly something like: xpath(xml(outputs('XML File')), '??????')
 
<?xml version="1.0" encoding="utf-8"?>
</ShipmentProfileReport>
  <ShipmentProfileReportItem>
    <JobOperator>John Doe</JobOperator>
     <Master>17231888581</Master>
  </ShipmentProfileReportItem>
  <ShipmentProfileReportItem>
    <JobOperator>Jane Doe</JobOperator>
    <Master>78423082032</Master>
  </ShipmentProfileReportItem>
</ShipmentProfileReport>

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @acrespo,

 

xml() function and xpath() function neither of them can do it.

As a workaround, you could use split() function and index to approach that:

split(split(outputs('XML'),'<')[2],'>')[0]

Screenshot 2021-02-27 095241.jpg

Run result:

Screenshot 2021-02-27 095206.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

1 REPLY 1
v-litu-msft
Community Support
Community Support

Hi @acrespo,

 

xml() function and xpath() function neither of them can do it.

As a workaround, you could use split() function and index to approach that:

split(split(outputs('XML'),'<')[2],'>')[0]

Screenshot 2021-02-27 095241.jpg

Run result:

Screenshot 2021-02-27 095206.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.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,247)