xml 找出 XPath 的工具

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1915219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 12:53:13  来源:igfitidea点击:

Tool to find out XPath

xmlopen-sourcexpath

提问by Burt

I find XPath difficult to get my head around at times and am looking for a tools that I can point at a line in an xml config file an it will tell me the xpath to the attributes that I need.

我发现 XPath 有时难以理解,我正在寻找一种工具,我可以将其指向 xml 配置文件中的一行,它会告诉我我需要的属性的 xpath。

Any help with this would be much appreciated>

对此的任何帮助将不胜感激>

采纳答案by James Kolpack

I've used the "Buba XPath builder" to do this. SketchPath (now XMLQuire) may also do the trick:

我已经使用“Buba XPath builder”来做到这一点。SketchPath(现在是 XMLQuire)也可以做到这一点:

http://qutoric.com/xmlquire/

http://qutoric.com/xmlquire/

回答by Ta01

Visual XPathis full of win.

Visual XPath充满胜利。

回答by Dolphin

If you use firefox you might want to check out XPather. Even if you find another tool, this is a handy thing to have around when you just want to check something out quickly if you are like me and almost always have a browser window already open.

如果您使用 firefox,您可能想查看XPather。即使您找到了其他工具,如果您像我一样并且几乎总是已经打开了浏览器窗口,那么当您只想快速查看某些内容时,这也是一个方便的工具。

回答by user1029415

Xpather is the best tool to find the xpath.

Xpather 是查找 xpath 的最佳工具。

http://xpath.alephzarro.com/

http://xpath.alephzarro.com/

回答by Amit Shakya

The Best tool is Firepath when it is installed over Firebug. You can easily find the Xpath using it. But it only works with Mozilla The Download link is: https://addons.mozilla.org/en-US/firefox/addon/firepath/Or simply go to addons and click get extensions and type firepath.

当它安装在 Firebug 上时,最好的工具是 Firepath。您可以使用它轻松找到 Xpath。但它仅适用于 Mozilla 下载链接是:https: //addons.mozilla.org/en-US/firefox/addon/firepath/ 或者只需转到插件并单击获取扩展并键入 firepath。

You need to have firebug installed.

您需要安装萤火虫。

回答by anotherdave

I want to echo XPatheras my tool of choice, although it's not yet (as far as I'm aware) available for the latest version of FF. In order to better learn XPath, XPather gives you two good benefits:

我想将XPather作为我选择的工具来回应,尽管它尚未(据我所知)可用于最新版本的 FF。为了更好的学习XPath,XPather给了你两个很好的好处:

  1. You can tinker with the XPath in the window dialogue and see how it affects which elements are matched. In this way you can make your paths more general & slowly build on them but while making sure you're getting no false positives. This is how I learnt XPath.
  2. It has an in-built 'cheat sheet' of selectors you won't use thatoften, but you want to have to hand when you need them — sibling, parent, does not contain etc.
  1. 您可以在窗口对话框中修改 XPath 并查看它如何影响匹配的元素。通过这种方式,您可以使您的路径更通用并慢慢地建立在它们的基础上,同时确保您没有误报。这就是我学习 XPath 的方式。
  2. 它有一个内置的选择器“备忘单”,您不会经常使用它们,但是您希望在需要时使用它们——兄弟、父、不包含等。

Most of the time in my work I find it's not important to find anXPath that matches, but the best match for what I'm looking for (most specific for speed, most general for flexibility and matching similar nodes).

在我工作的大部分时间里,我发现找到匹配XPath并不重要,但最适合我正在寻找的东西(最具体的速度,最通用的灵活性和匹配类似的节点)。

Firebug itself will give you an exact XPath for an element, but it makes me think of writing automation tests in Selenium recorder — it's OK if you're targetting that particular node that will always be in that exact location on the page. Whereas you could be targeting an ad banner that you don't know the exact location of, but know it's rough whereabouts — the RHS column on every page, for instance. This often happens with a CMS backed site, if you're testing against a system that real content-editors are using too.

Firebug 本身会为您提供一个元素的精确 XPath,但它让我想到在 Selenium 记录器中编写自动化测试——如果您的目标是始终位于页面上该确切位置的特定节点,那也没关系。而您可以定位一个您不知道确切位置但知道其大致位置的广告横幅 - 例如,每个页面上的 RHS 列。如果您正在针对真正的内容编辑器也在使用的系统进行测试,那么这通常发生在 CMS 支持的站点上。

回答by dwo