Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
REXML XPath question
Ja Ha
6/25/2007 9:07:00 PM
Can anyone explain these result to me (see bottom)?
require 'rexml//document'
d = REXML::Document.new %{
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd...
<html xmlns="
http://www.w3.org/1999/x...
xmlns:foo="uniq"
xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"
/>
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>test</title>
</head>
<body>
<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>
</div>
</body>
</html>
}
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'> ... </>]
--
Posted via
http://www.ruby-...
.
2 Answers
Ja Ha
6/25/2007 9:33:00 PM
0
OK I just removed xmlns="
http://www.w3.org/1999/x...
from the <html>
tag (the default namespace) and now it works.
Is this a bug?
--
Posted via
http://www.ruby-...
.
Ja Ha
6/25/2007 10:18:00 PM
0
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.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
REXML XPath question
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password