Forum: Ruby REXML XPath question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ja H. (Guest)
on 2007-06-26 01:06
Can anyone explain these result to me (see bottom)?

require 'rexml//document'
d = %{
<html xmlns="" xmlns:foo="uniq"
    <meta http-equiv="content-type" content="text/html; charset=utf-8"
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <p id="foo">3</p>
    <p id="bar">4</p>
    <div id="div">
        <p id="baz" foo:attr="here">5</p>
        <p id="bat" class="wag">6</p>

REXML::XPath.match d, "/html/body/p[@id='foo']"
#-> []

REXML::XPath.match d, "/html/body/p[@id]"
#-> []

REXML::XPath.match d, "/html/body/p[@*]"
#-> [<p id='foo'> ... </>, <p id='bar'> ... </>]
Ja H. (Guest)
on 2007-06-26 01:32
OK I just removed xmlns="" from the <html>
tag (the default namespace) and now it works.

Is this a bug?
Ja H. (Guest)
on 2007-06-26 02:18
Wow, 2 replies from myself...

I just found out that XPath 1.0 does not work correctly with a default
namespace. So this is "correct" behavior.
This topic is locked and can not be replied to.