Working with large XML files without losing your sanity


Speaking as a Sitecore developer, XML files have the tendency to become so large that it’s tricky to figure out where exactly you’re working, seen from an XPath perspective. This makes the process of creating e.g. Sitecore include files tedious and error prone.

A while ago I created a small Visual Studio plugin which keeps track of the XPath matching your cursor position when working in files containing XML-markup (e.g. Web.config, NAnt files, MSBuild files, Solr configuration files, Spring.NET files … you get the point). I’ve recently released v3 of the plugin and thought it was about time to do a new writeup of the features.

The plugin can be installed either by downloading it from the Visual Studio Gallery ( or by opening “Tools -> Extensions and Updates…” and searching for “XPath”.

Plugin installation


The source code can be found at



The XPath matching the current caret position is shown in the Visual Studio statusbar:

Screenshot - Statusbar

Copy XML structure

The basics for a Sitecore include file can be created easily with the “Copy XML structure” command. Simply select an element and choose “Copy XML structure” from the context menu:

Screenshot - XML Structure copy


Screenshot - XML Structure paste


Note that xmlns:patch="" is not added to the root automatically.

Copy XPath

It’s possible to copy the XPath at the current caret position in 3 different ways:

  • Generic – matches one or more elements
  • Absolute – matches the current element by index
  • Distinct – attempts to determine an XPath which only matches the current element by using distinct attribute values of the current node and its ancestors
Screenshot - Copy XPath

XPath variations available from the context menu.


It’s possible to configure which attributes are copied to the clipboard from the XPath options page found in “Tools -> Options -> XPath Information”. Check the option descriptions for details.

Screenshot - Options

XPath Information options page

For personal use I’ve configured the attributes “id”, “name”, “type” and “method” to be used in distinct paths, as these make most sense (to me) when working with Sitecore. This way I can quickly copy the correct XPath to the clipboard when using e.g. “patch:before” in Sitecore include files.

My XPath settings for the "Copy distinct XPath" command

My XPath settings for the “Copy distinct XPath” command.

Example of the distinct XPath to a Sitecore pipeline processor

Example of the distinct XPath to a Sitecore pipeline processor when using the value of the “type” attribute, which is unique for this element among its siblings.

Please use for feature requests and bug reports.
If you find the plugin helpful please rate it on Visual Studio Gallery. 🙂