cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
radsab_58
Frequent Visitor

Set XML element value

Hi,

 

When I use set XML element value, I am getting the error "Xpath expression returned no element". Please refer to the screenshots.

 

radsab_58_0-1650394646072.png

radsab_58_1-1650394682272.png

and the xml code:

 

radsab_58_2-1650394929395.png

I want to set the value for attribute "Id", but getting the error. Please help.

 

 

 

3 REPLIES 3
VJR
Super User
Super User

After removing the namespace xmlns it is working so definitely that is obstructing the xpath.

 

https://codebeautify.org/Xpath-Tester

VJR_0-1650424115891.png

 

 

Looks like there are some ways to bypass it 

https://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath

https://stackoverflow.com/questions/4440451/how-to-ignore-namespaces-with-xpath

 

If you are not able to get the right way by doing a web search for this, then you could think of replacing the xmlns with a blank string and then set the new element value and then put back the xmlns. Just a thought.

kinuasa
Resolver I
Resolver I

Below is a sample using the XPath function.

/*[name()='Offering' and namespace-uri()='http://hogehoge.com/ns']/*[name()='OfferInXml']/*[name()='Data']/*[name()='Offer' and namespace-uri()='urn:nms:offer']/*[name()='Metadata']/*[name()='Id']

 

Hi, It worked! thanks 

and may I know is it possible to get more attributes at once, for example under a particular tag, I need to extract all the tags value.

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

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.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,597)