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?
xml microsoft-edge xpath
Sam hanley
source share