Easily generate XPath expressions in Visual Studio Code directly from your XML files with advanced smart relative paths, namespace support, virtual roots, and customizable templates.
✨ Features
📋 Copy XPath from cursor position with Ctrl+Shift+C
🔍 Search with XPath - Find elements using XPath expressions (Ctrl+Shift+F)
🌍 Universal XPath - Generate XPaths that work across different files
📊 Live XPath preview in status bar
🚀 Smart Relative Paths - Generate concise XPaths using significant elements
🎨 Multi-line formatting for readable complex XPaths
⚡ Single-line mode for compact expressions
🏷️ Virtual root support - Start XPaths from any ancestor element
🔗 Namespace-aware generation with custom prefixes
🎯 Attribute-based indexing - Group elements by attribute values
📁 Works with .xml, .xsd, .xsl, .xaml, .svg, .xhtml, .wsdl, and more!
⚡ Quick Start
Open any XML file
Place your cursor on an element
Use Ctrl+Shift+C to copy the XPath
Or click the XPath in the status bar
⚙️ Commands & Shortcuts
🎯 Core Commands
Command
Description
Shortcut
XML XPath: Copy XPath from Cursor
Copies XPath for current element
Ctrl+Shift+C
XML XPath: Search with XPath
Find elements using XPath
Ctrl+Shift+F
XML XPath: Copy Universal XPath
Generate XPath with universal settings
-
🚀 Smart Relative Path Commands
Command
Description
Shortcut
XML XPath: Toggle Smart Relative Path
Enable/disable smart relative mode
Ctrl+Shift+X
XML XPath: Set Smart Relative Namespace Prefix
Configure namespace prefix (e.g., 'd', 'ns')
-
XML XPath: Set Smart Relative Significant Attributes
Set attributes that make elements significant
-
XML XPath: Toggle Smart Relative Single Line
Switch between multi-line and single-line format
-
XML XPath: Set Smart Relative Virtual Root
Set element to start XPath from
-
XML XPath: Toggle Virtual Root Mode
Include/exclude virtual root in output
-
XML XPath: Toggle Ignore Last Element
Exclude target element (show container path)
-
🔧 Configuration Commands
Command
Description
XML XPath: Set Parent Tag
Sets a tag from which XPath should be generated
XML XPath: Set XPath Mode
Choose between indices, attributes, both, or simple