Parameterizing REXML::XPath expressions

S

Sy

Hi there,

I'm struggling a bit with what I think should be straightforward.

I basically want to pull information out of an XML document.

The working example I have is as follows...

version = REXML::XPath.match(@doc, '//[@pn="123-4567-89"]/
@version').to_s

However, I don't want to hardcode the value of the part number (pn).
I want to ref it via a variable.

e.g. if I have a variable 'partnum' which is set to "123-4567-89"

then I was expecting the expression to be something like...

version = REXML::XPath.match(@doc, '//[@pn=partnum]/
@version').to_s # no match

I've tried some variations but with same no match result.
But basically I'm just guessing which is bad.


All of the REXML tutorials always hardcode their examples.
Any help would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top