Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When I open an xml file in Visual Studio and browse it, I want to get the xpath of a certain node at the cursor like right click and choose "get xpath from this node" or something like that. How can we do that in Visual Studio 2010 or which tools/addons to use to do that?

Hope to hear from you all.

like image 780
Nam G VU Avatar asked Jun 30 '10 10:06

Nam G VU


1 Answers

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.

like image 101
MindingData Avatar answered Sep 28 '22 04:09

MindingData