Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to select a specific XML node with XPath

Not applicable
Hi,

I'm trying to a select a specific node from my XML data using the XPath Builder. For example, say I have a process variable 'xmlData' with the
following contents:



User 1
101


User 2
102



I can successfully use the following expression to retrieve the name of
a specific user:

(/process_data/xmlData/users/user[userid='102'])/name

The problem is I need to use another process variable for the selection
key. For Example:

(/process_data/xmlData/users/user[userid=/process_data/@userId])/name

But this always returns null. I've tried surrounding /process_data/@userId
with single quotes, double quotes, and event {$..$}.

Any help would be greatly appreciated.

Thanks.
8 Replies
_jerome_dinnat_
Level 5
Level 5
Hi,



Try number(/process_data/@userid) but I'm not sure
Jasmin_Charbonn
Level 10
Level 10
Jerome is right try the following:



/process_data/xmlData/users/user[userid='number(/process_data/@userId)']/name



Jasmin
Not applicable
Hi,

Thanks for the quick replies. I gave a bit of a bad example, as the
userid in my data is really a string, not a number.

A better example is:



User 1
user1


User 2
user2



I can get the following to work perfectly:

(/process_data/xmlData/users/user[userid='user2'])/name

but I can't get it to work with

/process_data/@userId = "user2"

(/process_data/xmlData/users/user[userid=/process_data/@userId])/name

Thanks.
Jasmin_Charbonn
Level 10
Level 10
Don't forget the quotes around /process_data/@userid



/process_data/xmlData/users/user[userid='/process_data/@userId'])/name



Jasmin
Not applicable
Hi,



I've tried surrounding with single quotes, then double quotes, even

the template operators {$/process_data/@userId$}, and then the template

operators surrounded by single and double quotes. None of these

seem to work.
Not applicable
Hi,

Is there any solution? I encounter the same problem. Seem like a simple job but difficult to archeive...
Not applicable
have you found a solution to your problem,if not email me

mergeandfuse@gmail.com,will help you out

thaanks

girish
HowardTreisman
Level 9
Level 9
Just a thought: try:

/process_data/xmlData/users/user[userid=string(/process_data/@userId)])/name

Please post a reply if this works/doesn't.

Howard

http://www.avoka.com