Back to Skills

xml-element-extractor

verified

Extract specific XML elements from source files using Python and optionally format with xmllint. This skill should be used when users need to isolate a single XML element (like InstrumentVector with Id="0") from a larger XML document, preserving the complete element structure including opening and closing tags.

View on GitHub

Marketplace

alsdiff-tools

krfantasy/alsdiff

Plugin

xml-element-extractor

utilities

Repository

krfantasy/alsdiff
1stars

plugins/xml-element-extractor/skills/xml-element-extractor/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/krfantasy/alsdiff/blob/main/plugins/xml-element-extractor/skills/xml-element-extractor/SKILL.md -a claude-code --skill xml-element-extractor

Installation paths:

Claude
.claude/skills/xml-element-extractor/
Powered by add-skill CLI

Instructions

# XML Element Extractor

## Overview

This skill enables precise extraction of XML elements from source files using Python's standard library (xml.etree.ElementTree), with optional xmllint formatting for clean output. Use this skill when you need to isolate a specific XML element from a larger document while maintaining its complete structure.

## ⚠️ Agent Guidelines

**DO NOT READ XML FILES DIRECTLY**

- **Never use Read tool on XML files** - Large files can exceed context limits
- **Never display XML content directly** - Always use the extraction script
- **Always use the Python extraction script** - Optimized for efficient XML processing
- **Process XML externally** - Let the script handle parsing, not the agent

This prevents context overflow and maintains performance.

**Key advantages of the Python implementation:**
- **Maximum compatibility**: Uses only Python standard library, no third-party dependencies
- **Robust parsing**: Proper XML parsing handles complex structures, special characters, and encoding
- **Attribute order insensitive**: Works regardless of attribute order in XML tags
- **Better error handling**: Provides clear error messages and graceful failure handling
- **Cross-platform**: Works consistently across different operating systems

## Quick Start

To extract an XML element:

1. Identify the source XML file path
2. Choose destination file path for the extracted element
3. Specify the exact opening tag (including attributes) of the element to extract
4. Execute the extraction script
5. Verify the output file contains the desired element

## Extraction Process

### Step 1: Prepare Input Parameters

Gather the following parameters:
- **Source XML file**: Path to the input XML file containing the element to extract
- **Destination XML file**: Path where the extracted element will be saved
- **Element tag**: Exact opening tag including all attributes (e.g., `<InstrumentVector Id="0">`)

### Step 2: Execute Extraction Script

Run the extraction scr

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
6380 chars