Closed
Bug 353858
Opened 18 years ago
Closed 18 years ago
Querying element by names with xpath returns empty results in application/xhtml+xml type
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: medikoo+mozilla.org, Unassigned)
References
()
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 Any query for element with specific name like '//body' will return empty result, when document is of application/xhtml+xml type. Queries that doesn't address specific element names returns expected values. Like '//*' will return expected result. Reproducible: Always Steps to Reproduce: 1.Create empty xhtml document 2.add js script line: alert(document.evaluate('count(//body)', document, null, XPathResult.NUMBER_TYPE, null).numberValue); 3. Run document as application/xhtml+xml type Actual Results: alert box will throw '0' Expected Results: alert box should show '1' Doesn't occur with text/html type.
Reporter | ||
Updated•18 years ago
|
Component: General → DOM
Product: Firefox → Core
Version: unspecified → 1.8 Branch
Updated•18 years ago
|
Assignee: nobody → general
QA Contact: general → ian
Your test case uses a namespace and Firefox is correctly disregarding <body xmlns="http://www.w3.org/1999/xhtml"> elements because your XPath is asking for plain <body> elements. To use the namespace, include a prefix in your XPath and supply a function as the third argument to document.evaluate() to translate the prefix into the namespace. This, for instance: alert(document.evaluate('count(//html:body)', document, function(prefix){return (prefix == 'html' ? 'http://www.w3.org/1999/xhtml' : '');}, XPathResult.NUMBER_TYPE, null).numberValue); See http://www.w3.org/TR/DOM-Level-3-XPath.
Reporter | ||
Comment 2•18 years ago
|
||
Thanks for that explanation. I wasn't aware of that. Sorry for invalid submit. I'm changing status to INVALID
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → INVALID
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•