开发者

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 nod开发者_Go百科e 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.


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".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜