Using Chrome extension to reveal a XPath

Build 1501 on 14/Nov/2017  This topic last edited on: 22/Mar/2016, at 16:54

To reveal a XPath with Chrome

In Chrome, you may want to install the XMLTREE extension:

https://chrome.google.com/webstore/detail/xml-tree/gbammbheopgpmaagmckhpjbfgdfkpadb

Once installed, you can use it to get the corresponded XPath expression while navigating XML.

For an example of getting XPath for pages, see Getting XML from database by objsnav command. When you have a full XML, then perform the following steps:

1.Use the browser's Find function to find the attribute you need, e.g. zoneRef (page.zoneRef).

2.Click the attribute and you will have something as

Click to toggle graphic size

3.Copy the string from the extension box, e.g. /page/zoneRef/nav:refObject/zone/extraStr, and modify it, by adding for all not "nav" elements, the gn4 prefix, e.g.

4./gn4:page/gn4:zoneRef/nav:refObject/gn4:zone/gn4:extraStr

Notes

If you click the zone name, the XPath is: /page/zoneRef/nav:refObject/zone/@name

For the attribute (@) there is no need to add the namespace, as attributes inherits the name space of the containing element, so you can specify just @name without a prefix.