← All tools

Data & Analysis

XML Parse

XPath queries and element listing.

xml_parse

Overview

Reads XML, an older data format still used by things like news feeds, enterprise APIs, and regulatory filings. Pulls out specific pieces so the agent can work with them just like any other data.

How it works

Accepts an XML document and applies one of three operations: 'xpath' evaluates an XPath 1.0 expression and returns matching values; 'elements' lists every element name and its path; 'text' extracts all visible text, stripping tags. Works on RSS/Atom feeds, SOAP responses, sitemaps, and regulatory XML.

Example

When a user asks:

Grab all the article titles from this RSS feed.

the agent calls the tool:

xml_parse(xmlContent="…", operation="xpath", xpath="//item/title/text()")

and gets back: a list of every `<title>` under `<item>` in the feed.

Use it in a workflow

Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.

YAML DSL

# feed-reader.yaml
name: feed-reader-crew
process: SEQUENTIAL

agents:
  - id: reader
    role: Feed Reader
    goal: Parse XML feeds and enterprise responses
    tools:
      - xml_parse

tasks:
  - id: feed-reader-task
    agent: reader
    description: Return every <title> element from the supplied RSS feed.

Java

import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.XMLParseTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;

@Autowired ChatClient chatClient;
@Autowired XMLParseTool xMLParseTool;

Agent reader = Agent.builder()
    .role("Feed Reader")
    .goal("Parse XML feeds and enterprise responses")
    .chatClient(chatClient)
    .tool(xMLParseTool)
    .build();

Task readerTask = Task.builder()
    .description("Return every <title> element from the supplied RSS feed.")
    .agent(reader)
    .build();

SwarmOutput result = Swarm.builder()
    .agent(reader)
    .task(readerTask)
    .process(ProcessType.SEQUENTIAL)
    .build()
    .kickoff();

What it's good for

Real scenarios where agents put this tool to work.

RSS/Atom feed parsing in research crews
SOAP / enterprise XML API integrations
XPath extraction from config or sitemap files
SEC XBRL / EDGAR XML snippet reading

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/XMLParseTool.java in the swarm-ai repository.

Open xml_parse on GitHub →