Nokogiri xml namespaces

So when using nokogiri xml_element.xpath(path), you can pass a second
argument hash of alias to namespace URI, to use namespaces.

This works fine. But it's inconvenient to be passing the hash on every
call, when it's pretty much always the same hash, for several calls.

It seemed to me there ought to be a way to set the default namespace
alias mapping on the xml element itself, so it'll just stick for calls
on that element, and won't need to be explicitly passed in on every
xpath call.

nokogiri has generally such a convenient api that I figured this must be
there... but I haven't been able to find it.

Anyone know if it is?

···

--
Posted via http://www.ruby-forum.com/.

There is no API for doing this. However, I am open to suggestions.
Could you write out in pseudo code (or ruby) what you're looking for?

···

On Wed, Oct 20, 2010 at 07:14:07AM +0900, Jonathan Rochkind wrote:

So when using nokogiri xml_element.xpath(path), you can pass a second
argument hash of alias to namespace URI, to use namespaces.

This works fine. But it's inconvenient to be passing the hash on every
call, when it's pretty much always the same hash, for several calls.

It seemed to me there ought to be a way to set the default namespace
alias mapping on the xml element itself, so it'll just stick for calls
on that element, and won't need to be explicitly passed in on every
xpath call.

nokogiri has generally such a convenient api that I figured this must be
there... but I haven't been able to find it.

Anyone know if it is?

--
Aaron Patterson
http://tenderlovemaking.com/