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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to insert variable...
Power Automate
Unanswered

How to insert variable in power automate xpath expression

(0) ShareShare
ReportReport
Posted on by 10

Hello,

 

Trying to replace "FacturaElectronica" in the expression bellow by a variable: variables('TipoDoc'). Tried to build the string with concat() but have not been able to make it work. 

 

xpath(xml(outputs('Obtener_contenido_de_XML_2')), 'string(/*[name()="FacturaElectronica"]/*[name()="Emisor"]/*[name()="Nombre"])')
 
Any suggestions? Thanks
Categories:
I have the same question (0)
  • manuelstgomes Profile Picture
    6,625 on at

    Hi @acrespo 

     

    Try copying with the following structure:

    @{variables('TipoDoc')}

     

    Cheers
    Manuel

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • acrespo Profile Picture
    10 on at

    Thanks Manuel - 

     

    This gives me an invalid expression and doesn't allow to save even (also without the @):

    xpath(xml(outputs('Obtener_contenido_de_XML_2')), 'string(/*[name()=@{variables('TipoDoc')}]/*[name()="Emisor"]/*[name()="Nombre"])')

     

    This is the closest I have gotten but somehow the xpath doesn't work, it just returns the concatenated string instead of the xml content: 

    xpath(xml(outputs('Obtener_contenido_de_XML_2')), concat('''string(/*[name()=',variables('TipoDoc'),']/*[name()="Emisor"]/*[name()="Nombre"])'''))

     

    Any other ideas I should try?

     

    Thanks,

  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @acrespo,

     

    You could do like this:

    1. Store the Xpath into a Compose action;

    string(/*[name()="@{variables('TipoDoc')}"]/*[name()="Emisor"]/*[name()="Nombre"])

    2. Append the output of Compose into the second parameter of Xpath() function:

    xpath(xml(outputs('Obtener_contenido_de_XML_2')), outputs('Compose_4'))

    Screenshot 2021-03-01 112532.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.

  • darkramuh Profile Picture
    11 on at

    If you using a lot of Xpath expressions in one action and don't want to create for each separate "Compose" action as per previous answer, You also can use "concat"

     

    xpath(xml(outputs('Obtener_contenido_de_XML_2')), concat('string(/*[name()=',variables('TipoDoc'),']/*[name()="Emisor"]/*[name()="Nombre"])'))

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard