JavaScript XPath fails with mixed-caps in element names




12 years ago
a month ago


(Reporter: westbaystars, Unassigned)


Firefox Tracking Flags

(Not tracked)


(Whiteboard: [CLOSEME 2010-11-01])



12 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv: Gecko/20061204 Firefox/
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv: Gecko/20061204 Firefox/

Running XPath queries on XML documents where all element names are all lower case works fine.  However, XML documents with mixed case fail.

Works: "//person/personid"
    . . .
  . . .

Fails: "//Person/PersonID"
    . . .
  . . .

Reproducible: Always

Steps to Reproduce:
1. Setup xpath method:

xpath = function (doc, path, asString) {
	var type = XPathResult.ANY_TYPE;
	if (asString) {
		type = XPathResult.STRING_TYPE;
	if (!doc) {
		return null;
	var rValue = document.evaluate(path, doc, NSResolver, type, null);
	if (asString) {
		return rValue.stringValue;
	} else {
		return rValue;

2. AJAX application queries XML document

3. XML document with mixed case tag names is returned to callback function as doc

4. var pid = xpath(doc, "//Person/PersonID", true);

5. Try with "//person/personid"

6. Return XML with all lower case element names
Actual Results:  
#4 returns an empty string to pid

#5 returns an empty string to pid

#6 returns "1" to pid - correct

Expected Results:  
Expected "1" for both #4 and #6.

Expected empty string for #5.

Using FireBug, I see that tag names (localName, tagName, nodeName properties) are in mixed case for the various nodes in the result XML document.  However, it shows the node for PersonID as "<personid>" in the debugger.  I don't know if that is something that FireBug displays or if it's something in the Mozilla DOM.
This is a mass search for bugs that are in the Firefox General component, are UNCO, and have not been changed for 1000 days and have an unspecified version. 

Reporter, can you please update to Firefox 3.6.10, create a fresh profile,, and test again. If you still see the bug, please update this bug. If the issue is gone, please set the resolution to RESOLVED > WORKSFORME.
Whiteboard: [CLOSEME 2010-11-01]
No reply from reporter, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile ( If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Last Resolved: 8 years ago
Resolution: --- → INCOMPLETE

Comment 3

a month ago
Problem exists in version 60.3.0

<!DOCTYPE html>
<html lang="en">
	<meta charset="utf-8" />
				<str>lower case element test</str>
				<str>mixed case element test</str>
	var xpe = new XPathEvaluator();
	// lower
	var lowerStr = xpe.evaluate("//tox/data/lower/str",document,null,XPathResult.STRING_TYPE,null);
	console.log("lowerStr = "+lowerStr.stringValue);
	var lowerInt = xpe.evaluate("//tox/data/lower/int",document,null,XPathResult.NUMBER_TYPE,null);
	console.log("lowerInt = "+lowerInt.numberValue);
	// mixed does not work in Firefox
	var mixedStr = xpe.evaluate("//tox/data/miXed/str",document,null,XPathResult.STRING_TYPE,null);
	console.log("mixedStr = "+mixedStr.stringValue);
	var mixedInt = xpe.evaluate("//tox/data/miXed/int",document,null,XPathResult.NUMBER_TYPE,null);
	console.log("mixedInt = "+mixedInt.numberValue);
You need to log in before you can comment on or make changes to this bug.