How to get the xpath of a certain node when viewing an xml file in Visual Studio? How to get the xpath of a certain node when viewing an xml file in Visual Studio? xml xml

How to get the xpath of a certain node when viewing an xml file in Visual Studio?


I am unsure of a Visual Studio tool that does this (Although I am sure there is one). For me, I use Notepad++ (Is there anything it can't do!?).

  1. Inside Notepad++ go to Plugins -> Plugin Manager -> Show Plugin Manager
  2. Install XML Tools
  3. Restart Notepad
  4. Load your XML Doc
  5. Place your cursor onto the node you are looking to generate the xpath for
  6. Go Plugins -> XML Tools -> Current XML Path (Default Hotkey : Ctrl + Alt + Shift + P)

This will only be able to give you the very basic XML tree traversal, but it's a start.

No tool will be able to generate any sort of complicated xPath for attribute checking etc. For those things often it is trial and error. You can use an online xPath tester to test your expressions against your XML anytime. Something like http://www.freeformatter.com/xpath-tester.html should be a great help.


The extension you want is called "XPath Information". In Visual Studio go to Tools -> Extensions and Updates -> Online -> Search for "XPath Information".