# Libxml-ruby namespace problem

**URL:** <https://www.ruby-forum.com/t/libxml-ruby-namespace-problem/118373>\
**Category:** Ruby\
**Created:** [October 26, 2007, 7:35am UTC](https://www.ruby-forum.com/t/libxml-ruby-namespace-problem/118373 "2007-10-26T07:35:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mortee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mortee](https://www.ruby-forum.com/u/mortee)\
**Post date:** [October 26, 2007, 7:35am UTC](https://www.ruby-forum.com/t/libxml-ruby-namespace-problem/118373/1 "2007-10-26T07:35:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mortee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mortee](https://www.ruby-forum.com/u/mortee)\
**Post date:** [October 26, 2007, 7:52am UTC](https://www.ruby-forum.com/t/libxml-ruby-namespace-problem/118373/2 "2007-10-26T07:52:28Z")

</div>

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.
