xml-surgeon

Edit XML data across multiple files using XPath-based reads and writes.

1|Updated Jan 18, 2026
One-click install
npx skills add https://github.com/anntnzrb/agents --skill xml-surgeon
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: xml-surgeon
Source: https://github.com/anntnzrb/agents/tree/main/assets/skills/xml-surgeon
Command: npx skills add https://github.com/anntnzrb/agents --skill xml-surgeon

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires lxml>=5.3.0, and includes scripts (resource) components.

What problem does it solve?

xml-surgeon enables precise, surgical edits of XML data across many files using XPath, while minimizing formatting drift and preserving the original structure as much as possible.

Core Features & Use Cases

  • XPath-based reads/edits with minimal formatting change across multiple files
  • Subtree inspection, child-node scanning, and updates to attributes/text, including insert/replace/delete
  • Batch refactors and targeted XML maintenance across large codebases or data stores

Quick Start

Inspect matches with select, preview changes with show or context, then apply surgical edits using set-text, set-attr, insert, replace, or delete after reviewing diffs.

Frequently Asked Questions about xml-surgeon

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I edit specific XML nodes across multiple files without breaking formatting?▼

XML batch processing can be done using XPath to target specific attributes, text, and nodes while preserving the original formatting. You inspect matches first, preview a diff, then apply changes in place.

What is the best way to batch update XML attributes using XPath?▼

Batch updating XML attributes via XPath allows you to select target elements across many files and apply set-attr operations. A dry-run diff previews all modifications before committing the in-place writes.

Can I use lxml to process very large or corrupted XML files?▼

lxml can process large or corrupted XML files using specific parser options. The script supports --huge for large-file handling and --recover to gracefully parse malformed XML structures during extraction.

Does XPath work for inserting and replacing XML subtrees?▼

XPath works for inserting, replacing, and deleting XML subtrees by targeting the exact node locations. You can perform structural modifications like child-node insertion or full subtree replacement while minimizing formatting drift.

How do I handle XML namespaces when making targeted edits?▼

Handling XML namespaces during targeted edits is supported natively by the script. It correctly resolves namespace prefixes during XPath reads and writes, ensuring surgical edits apply to the correct elements.