Categories

XML Path Extractor

Extract values from XML documents using XPath expressions. Perfect for extracting specific data from complex nested XML structures, API responses, RSS feeds, and configuration files.

XPath expressions to extract values. Examples: //* - All elements //book/title - All book titles //person[@age>18] - Persons older than 18 Leave empty to extract all elements

Include the XPath expression used for each extraction

Include attributes for extracted elements

Treat multiple results as individual items instead of arrays

Maintain the original order of elements in the XML document

Enable namespace-aware XPath evaluation

Include empty elements and null values in the extraction results

Key Facts

Category
Data Processing
Input Types
textarea, select, checkbox
Output Type
text
Sample Coverage
4
API Ready
Yes

Overview

The XML Path Extractor is a powerful utility designed to parse complex XML documents and retrieve specific data points using standard XPath expressions. Whether you are processing API responses, RSS feeds, or large configuration files, this tool allows you to pinpoint nested elements and attributes with precision.

When to Use

  • When you need to isolate specific data fields from large or deeply nested XML files.
  • When parsing API responses or RSS feeds to extract relevant content for further analysis.
  • When validating or auditing configuration files by querying specific element paths.

How It Works

  • Paste your XML document into the input field.
  • Define your target data using standard XPath expressions, such as //element/child.
  • Select your preferred output format, such as JSON, CSV, or a simple list.
  • Configure additional settings like namespace awareness or attribute inclusion, then execute the extraction.

Use Cases

Extracting product prices and titles from e-commerce XML product feeds.
Parsing server configuration files to identify specific settings or environment variables.
Converting complex API XML responses into structured JSON for web application integration.

Examples

1. Extracting Book Titles from Library XML

Data Analyst
Background
A library database exported a large XML file containing thousands of book entries with nested categories.
Problem
Need to extract only the titles of books categorized as 'fiction' for a reading list report.
How to Use
Paste the XML content, enter the XPath expression '//book[@category="fiction"]/title', and select 'Simple List' as the output format.
Outcome
A clean list of all fiction book titles extracted from the XML structure.

2. Parsing API Response for JSON Conversion

Web Developer
Background
An external API returns user data in a deeply nested XML format that the frontend application cannot read directly.
Problem
Need to convert specific user IDs and email addresses into a flat JSON array.
How to Use
Input the API XML response, use the XPath '//user/email', and set the output format to 'JSON Array'.
Outcome
A structured JSON array containing only the email addresses, ready for use in the application.

Try with Samples

xml

Related Hubs

FAQ

What is XPath?

XPath is a query language used for selecting nodes from an XML document, allowing you to navigate through elements and attributes.

Can I extract multiple values at once?

Yes, you can provide multiple XPath expressions, one per line, to extract different data points simultaneously.

Does this tool support XML namespaces?

Yes, you can enable the 'Namespace Aware' option to correctly process XML documents that utilize namespaces.

What output formats are supported?

The tool supports outputting results as a simple list, JSON array, CSV format, or raw XML.

Can I include element attributes in the output?

Yes, by checking the 'Include Element Attributes' option, the tool will extract attributes alongside element values.

API Documentation

Request Endpoint

POST /en/api/tools/xml-path-extractor

Request Parameters

Parameter Name Type Required Description
xmlInput textarea Yes -
xpathExpressions textarea No XPath expressions to extract values. Examples: //* - All elements //book/title - All book titles //person[@age>18] - Persons older than 18 Leave empty to extract all elements
outputFormat select Yes -
includePaths checkbox No Include the XPath expression used for each extraction
includeAttributes checkbox No Include attributes for extracted elements
flattenArrays checkbox No Treat multiple results as individual items instead of arrays
preserveOrder checkbox No Maintain the original order of elements in the XML document
namespaceAware checkbox No Enable namespace-aware XPath evaluation
nullValues checkbox No Include empty elements and null values in the extraction results

Response Format

{
  "result": "Processed text content",
  "error": "Error message (optional)",
  "message": "Notification message (optional)",
  "metadata": {
    "key": "value"
  }
}
Text: Text

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-xml-path-extractor": {
      "name": "xml-path-extractor",
      "description": "Extract values from XML documents using XPath expressions. Perfect for extracting specific data from complex nested XML structures, API responses, RSS feeds, and configuration files.",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=xml-path-extractor",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]