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 / xpath error - cannot b...
Power Automate
Unanswered

xpath error - cannot be evaluated because property 'ID' cannot be selected

(0) ShareShare
ReportReport
Posted on by 87

This is a follow up to "Power Automate xpath".  I have followed the detailed instructions posted by @Paulie78  to the letter with out success. The xpath() function returns the following error:

 

Function

 

xpath(outputs('XML'),concat('//Array[ID/text()="', item()['ID'],'"]/Size/text()'))[0]

 

 

Error returned:

 

InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language expression 'xpath(outputs('XML'),concat('//Array[ID/text()="', item()['ID'],'"]/Size/text()'))[0]' cannot be evaluated because property 'ID' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.

 

If I replace item()['ID'] with '3333', the xpath() works as expected and returns the expected result.

Flow:

AlexLindberg_1-1709233510647.png

[

{

"ID": "3333","Object_Name": "Power"

},{

"ID": "1111","Object_Name": "Automate"

},{

"ID": "2222","Object_Name": "Function"}

]

AlexLindberg_2-1709233608792.png

[

{

"ID": "1111","Size": "5"

},{

"ID": "2222","Size": "6"

},{

"ID": "3333","Size": "8"

},{

"ID": "4444","Size": "8"

}

]

AlexLindberg_6-1709234741003.png"Array": @{outputs('Array2')}
AlexLindberg_9-1709234973776.pngxml(outputs('PrepareArray2'))
AlexLindberg_4-1709233988451.png

Using a Compose step to check the xpath() construction

xpath(outputs('XML'),concat('//Array[ID/text()="', item()['ID'],'"]/Size/text()'))[0]

 

The output from XML is

 

 

 

<root>
	<Array>
		<ID>1111</ID>
		<Size>5</Size>
	</Array>
	<Array>
		<ID>2222</ID>
		<Size>6</Size>
	</Array>
	<Array>
		<ID>3333</ID>
		<Size>8</Size>
	</Array>
	<Array>
		<ID>4444</ID>
		<Size>8</Size>
	</Array>
</root>

 

 

 

The error message from the Compose Stage

AlexLindberg_5-1709234153002.png

 

 

 

InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language expression 'xpath(outputs('XML'),concat('//Array[ID/text()="', item()['ID'],'"]/Size/text()'))[0]' cannot be evaluated because property 'ID' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.

 

 

 

 I have also tried item()?['ID'].  No error message but returns an empty array.

 

Any guidance would be greatly appreciated.

 

Thank you for your time.

Alex

Categories:
I have the same question (0)
  • Verified answer
    Chriddle Profile Picture
    8,434 Super User 2025 Season 2 on at

    In a Compose action, there is no item() and therfore no item()['ID'].

     

    I assume, that you want to use a Select action with Array1 as "From" and use this expression to get the size of each Object from this array:

     

    Chriddle_0-1709246057904.png

    Select

    From

    outputs('Array1')

    Map ID

    item()['ID']

    Map Object_Name

    item()['Object_Name']

    Map Size

    xpath(
    	xml(outputs('Xml')),
    	concat('string(//Array[ID/text()="', item()['ID'],'"]/Size/text())')
    )

     

    Result

    [
     {
     "ID": "3333",
     "Object_Name": "Power",
     "Size": "8"
     },
     {
     "ID": "1111",
     "Object_Name": "Automate",
     "Size": "5"
     },
     {
     "ID": "2222",
     "Object_Name": "Function",
     "Size": "6"
     }
    ]

     

    That's the beauty of xpath: you can create complex queries within an expression to use in a Select action.

  • AlexLindberg Profile Picture
    87 on at

    Thank you for the clarification... It makes complete sense once you pointed out there was no "item()" available to the xpath function... (DUH).. 😃

    Using the Select function provides the values for "item()".

     

    A big thank you.

    Alex

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 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard