Libxml-ruby namespace problem

I’m trying to use libxml-ruby 0.5.2.0 on cygwin. The XML I want to parse
has a namespace declaration on the root node, but this namespace isn’t
given a prefix.

My problem is that when I try to match elements using e.g.
XML::Document#find, it won’t match any.

If I specified a prefix for the document’s NS in the XML file, and used
element names qualified by that prefix in the xpath expression, it finds
what I’m looking for. Also, if I remove the NS declaration from the root
node, then it finds elements with unspecified names in the xpath
expression.

Too bad I can’t tweak the XML input I’d have to handle like I can with
test files.

So my question is, how can I have libxml-ruby to ignore the namespace on
the document and find elements using unqualified names; or how can I
specify what namespace it should assume for the unqualified names in the
xpath?

The docs mention a namespace parameter to the #find method, but I was
unable to figure out how I’m supposed to specify the NS there.

thx
mortee

Follow-up to myself:

Actually, libxml-ruby won’t find what I’m looking for if either a
namespace or a DOCTYPE declaration is present in the document. I had to
remove both to get results.

If I have only the DOCTYPE in the document, it doesn’t raise an
exception for e.g. the document not conforming to the specified DTD, it
just returns empty result sets.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs