XPath API

The XPath API provides a way to locate and process elements in XML documents. As of Microsoft Edge, the Document Object Model (DOM) Level 3 XPath Specification is supported which offers native support in the DOM for XPath navigation and searching in XML documents.

In older versions of Windows Internet Explorer, developers had to use 3rd party libraries or a MSXML hack to provide XPath functionality. With Microsoft Edge, XPath API code that has worked in other browsers should work seamlessly in Microsoft Edge too.

For more information about XPath, check out Improving interoperability with DOM L3 XPath on the Microsoft Edge dev blog.

Example

The code below demonstrates a use of the new XPath functionality. It delivers the same results across all major browsers: logging the appropriate numbers within the span elements to the developer console.

See this example by Microsoft Edge Docs on CodePen.

Improving interoperability with DOM L3 XPath

Specification

Document Object Model (DOM) Level 3 XPath Specification