XPath expression using "and" not working in Microsoft Edge?

I am working on an application that uses XPath expressions to select nodes from XML. We noticed that this seems to break for us when testing in the Microsoft Edge preview. I shortened our code to a brief snippet that demonstrates the problem:

var xml = "<xml id='relationships'><Relationships><f id='some_id' ><f id='some_other_id' /></f></Relationships></xml>"; var doc = (new DOMParser).parseFromString(xml, "text/xml"); var nodes = doc.evaluate("//f[@id='some_id' and f]", doc, doc.createNSResolver(doc.documentElement), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); console.log(nodes.snapshotLength); 

In Chrome, this will exit system 1 , and nodes.snapshotItem will contain the correct node, but in Edge it will exit system 0 and will not return any nodes.

If I fulfill half of this condition separately, "//f[@id='some_id']" or "//f[f]" , it works sequentially in browsers, and Edge returns the correct node. It fails when these two conditions, as true for the node in question, are combined with and . I am not an XPath expert for any reason, so can someone tell me that I am doing something non-standard in this snippet, or if this seems like a problem with the implementation of Edge Preview XPath?

+4
xml microsoft-edge xpath
source share
2 answers

Update: this issue was resolved in a November 2015 update for Windows / Edge

This seems like a bug with the current implementation in Microsoft Edge. However, I noticed that if you flip the conditions around, the correct element is retrieved:

 //f[f and @id='some_id'] 

I currently hope this is an acceptable alternative. I open a mistake for our team to look at our end. How do you help us improve Microsoft Edge :)

+3
source share

XPaths, which does not work in Edge, followed by a similar alternative:

Crash

 '/value[Name/text()="Checked"]/Value[text()="true"]' 

Alternative

 '/value[Name ="Checked" and Value = "true"]/Value' 

Crash

 '/value[text()="match1"]' 

Alternative

 '/value[.="match1"]' 

Crash

 '/value[Name[text()="match1"]]' 

Alternative

 '/value[Name="match1"]' 

Crash

 '/value[Name/text()= "match1"]' 

Alternative

 '/value[Name= "match1"]' 

Crash

 '/value[Name[text() = 'match1']]') 

Alternative

 '/value[Name = "match1"]') 
+3
source share

All Articles