# XPath 搜索

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/idea/llms.txt).

IntelliJ IDEA 允许您使用 XPath 3.0 在当前项目、目录或自定义范围内的 XML 文件中查找特定的 XML 节点。

在撰写 XPath 表达式时，IntelliJ IDEA会为 XPath axes 提供代码补全并检查表达式语法。 它还提供了 XPath 语法高亮显示，可以在  `设置 | 编辑器 | 颜色方案 | XPath`  中自定义。

Procedure: 启用 XPathView + XSLT 插件

此功能依赖于 [XPathView + XSLT](https://plugins.jetbrains.com/plugin/12478-xpathview--xslt)插件，该插件默认在 IntelliJ IDEA 中捆绑并启用。 如果相关功能不可用，请确保您没有禁用插件。

> **Note:**
> XPathView + XSLT 插件默认仅在 IntelliJ IDEA Ultimate 订阅中可用。 对于 IntelliJ IDEA，您需要按 [插件](managing-plugins.html) 中的说明安装 XPathView + XSLT 插件。

1. 按 `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) 打开设置，然后选择  `插件` 。

2. 找到  XPathView + XSLT  插件并点击   启用  。

Procedure: 在 XML 文件中搜索

1. 在主菜单中，前往  `编辑 | 查找 | 通过 XPath 查找…` 。 将打开   通过 XPath 表达式查找   对话框。

2. 输入 XPath 表达式。

例如，下列表达式：

```XSD
//application[@title="BestApp"]/descendant::resource

```

将搜索  `resource`  标签，该标签是具有  `application`  标签的子元素，并且该标签具有值为  `BestApp`  的属性  `标题` 。

3. 选择搜索范围。

如果您选择   目录   并指定目录路径，您还可以选择   递归地   复选框以搜索所有子目录中的节点。

XPath 搜索结果显示在 [Find](find-tool-window.html) 工具窗口中。

