Sitemap URL Extractor and PDF Link Filter - n8n Workflow

Learn how to use this n8n workflow to read any sitemap.xml, convert it to JSON, and filter specific URLs (like PDFs) using core n8n node logic. Great n8n templates for developers.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

SEO Specialists needing to audit specific file types linked in their sitemap.
Developers looking for a robust n8n node approach to process XML data.
Automation enthusiasts who want reusable n8n templates for data cleaning and filtering.
Users who need to repeatedly extract and process links from large sitemap files using an n8n workflow.

Overview

Handling sitemap files is crucial for SEO analysis and data extraction, but they are often presented in complex XML format. This powerful n8n workflow solves this by streamlining the entire process. It starts by defining the sitemap URL, fetching the XML content, and using the n8n XML node to convert it into a structured JSON array. The key value of this n8n template lies in its ability to iterate over every single URL entry using the Split Out n8n node and then apply precise filtering rules. By default, it filters for PDF links, but users can easily adjust the filter to target any file type or path structure, providing a highly flexible and efficient solution within the n8n automation platform. This whole process is managed efficiently within a single n8n workflow.

How it Works

This n8n workflow is initiated by a manual "Test workflow" n8n trigger for immediate execution and testing.


  1. Set Configuration: The flow begins at the "Set sitemap URL" n8n node, where the target sitemap.xml URL (e.g., https://duckduckgo.com/sitemap.xml) is defined and passed as an input variable. Users must configure this n8n node.

  2. Fetch XML: The "Get Sitemap" n8n node executes an HTTP Request using the dynamic URL from the previous n8n node to download the raw XML content of the sitemap.

  3. Convert Data: The raw XML is immediately passed to the "Convert Sitemap to JSON" n8n node, which uses XML parsing capabilities to transform the structured document into a processable JSON object.

  4. Flatten Data: The "Split Out" n8n node takes the main URL array (urlset.url) and breaks it down, ensuring each URL entry is treated as a separate item, ready for individual evaluation by the subsequent n8n node.

  5. Apply Filter: Finally, the "Filter URLs" n8n node applies the core logic. In this n8n template, the filter checks if the loc property of the URL item ends with .pdf. Only items satisfying this condition proceed to the end of the n8n workflow execution.

Installation Guide

To utilize this specialized n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' -> 'Import from JSON' option. This creates the full n8n template structure.

  2. Set Up the Sitemap URL: Locate the "Set sitemap URL" n8n node (a Set n8n node). Edit the value of the sitemapUrl variable to the URL of the sitemap.xml you intend to process. This is a critical configuration step for the n8n workflow.

  3. Customize the Filter: Navigate to the "Filter URLs" n8n node. By default, this n8n node filters for links ending in .pdf. Adjust the condition settings to match your specific extraction needs (e.g., change .pdf to include specific subdirectories or other file extensions). This allows you to tailor the n8n templates.

  4. Execute the n8n Trigger: Use the "‘Test workflow’ trigger" n8n trigger to manually start the workflow and test the output. Once satisfied, you can change the initial n8n trigger to a different type, like a Cron n8n trigger, for scheduled runs of this n8n workflow.

Node Details

This efficient n8n workflow relies on several core n8n node components:

‘Test workflow’ trigger (Manual Trigger)
Function: Serves as the starting n8n trigger for manual execution and testing of the n8n workflow logic.
Key Configuration: None, it simply initiates the flow.
Set sitemap URL (Set n8n node)
Function: Stores the static sitemap URL (https://duckduckgo.com/sitemap.xml by default) into the item data under the key sitemapUrl. This makes the n8n workflow highly reusable.
Get Sitemap (HTTP Request n8n node)
Function: Fetches the external resource (the sitemap.xml file) using the URL provided by the previous n8n node.
Key Configuration: URL is dynamically set using expression: ={{ $json.sitemapUrl }}.
Convert Sitemap to JSON (XML n8n node)
Function: Crucial n8n node for data processing. It converts the fetched XML data into a structured JSON format, enabling easy manipulation in subsequent n8n nodes.
Key Configuration: Uses standard settings to ignore attributes and trim whitespace for clean output.
Split Out (Split Out n8n node)
Function: Splits the large JSON array containing all sitemap entries (urlset.url) into individual items. This is necessary to apply item-by-item filtering logic with the next n8n node.
Key Configuration: Field to split out is urlset.url.
Filter URLs (Filter n8n node)
Function: Applies conditional logic to keep only desired items, defining the extraction criteria for this n8n workflow.
* Key Configuration: Filters where the loc field (the actual URL) ends with .pdf. This is the primary customization point for this n8n workflow template.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Transforming complexity into simplicity.

Featured*