Skip to content
Doug P edited this page Feb 17, 2020 · 5 revisions

XPath, the (XML Path Language), is a query language for selecting nodes from an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers, or Boolean values) from the content of an XML document. The XPath language is based on a tree representation of the XML document, and provides the ability to navigate around the tree, selecting nodes by a variety of criteria. [source: Wikipedia]

dnGREP utilized Microsoft implementation of XPath which is based on XPath 1.0 standard.

Example:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
  <title lang="eng">Harry Potter</title>
  <price>29.99</price>
</book>
<book>
  <title lang="eng">Learning XML</title>
  <price>39.95</price>
</book>
</bookstore>

When search returns one or many Node Elements, the replace command will replace InnerXml with the value in the replace field.

Example 1

Search: /bookstore/book[1]

Replace: dnGrep

Result: the first book will become <book>dnGrep</book>

Example 2

Search: /bookstore/book[1]/title

Replace: dnGrep

Result: the first book title will become

<title lang="eng">dnGrep</title>

When search returns one or many Attributes, the replace command will replace Attribute Value with the value in the replace field.

Example 3

Search: /bookstore/book[1]/title/@lang

Replace: dnGrep

Result: the first book title will become

<title lang="dnGrep">Harry Potter</title>

Resources: XPath Syntax (W3School) XPath Tutorial (W3School)

Clone this wiki locally