05.15.07

XPath String Functions

Posted in Ruby at 11:03 am by Željko Filipin

I have XML that looks like this.

I need to get value of hash attribute (BF8E8F60E722E92C7ED8303916591AB4). I know the value of m url parameter (inside url attribute) (7fb83717-9606-4022-bd4e-67b6f6582ada), but I do not know the value of code url parameter.

I know how to get attribute of a tag when I know another attribute of that tag. For example, if I knew hash attribute and needed url attribute, I would do it like this:

But, I know only part of url attribute. Of course, this does not work (because e[...] returns nil).

I have heard that there are XPath string functions, but I did not understand how to use them, or would it even help in this case.

I have solved this problem with regular expressions, but I guess there must be XPath solution.

Also, I have already asked my developer to simplify that XML, so I can use it, but that has low priority because I have already solved the problem.

Angrez Singh was kind enough to help me. This is the solution.

You can find this thread at wtr-general.

Leave a Comment