Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

XPath and XML nodes

Avatar

Former Community Member
Hello

I've a simple problem but can't figure out the solution in ES Workbench (Process Designer). My process uses a xml variable called xmlvar that looks like:




form 1


form 2


form 3




For example: I want to get the name of the second anyform element. My index is stored in a counter variable called posCount (type int) and the value is 1. I've tried the XPath selection:
/process_data/xmlvar/data/formList/anyform[/process_data/posCount]/name

That doesn't work. I'm always getting the first value ("form 1").

Anybody know why?
Nico
4 Replies

Avatar

Level 10
Nico,

I have copy/pasted your XML into a file and created a process that reads the file from the file system, put the content into an XML variable and then use /process_data/xmlvar/data/formList/anyform[2]/name to put the name in a string variable and I do get "form 2".



Are you sure you're xml variable is populated properly? Can you put a variable logger before your SetValue to double check the content of the variable?



Jasmin

Avatar

Former Community Member
Strewth! This one was nasty... but finally I made it.



My approach had two failures:

* xml nodes, maps, list have not
0-based but
1-based indexes

* the statement has wrong syntax (but this
doens't result in an exception!!)



Ok, the correct statement look like this if your index is also a variable:


/process_data/xmlvar/data/formList/anyform[number(/process_data/posCount)]/name



That's it!

Nico

Avatar

Former Community Member
Thanks Jasmin for your great support!

Unfortunately I could solve my problem (almost) in the same minute as you were testing my problem.... sorry.



Nico

Avatar

Level 9
Hi Nico

The xpath expression probably doesn't throw an exception because it's still a valid xpath expression, it just doesn't result in the data that you're expecting.



What would be very helpful in xpath expressions is a way of evaluating an xpath expression against the real data of a particular process instance. If you feel this would be useful, please log it as a feature request with Adobe.



Howard

http://www.avoka.com