Power Plus - Datasource: XML
Loads data from any XML feed (RSS, Atom, or custom XML) and automatically converts it to JSON. Useful for legacy APIs, RSS blog feeds, and SOAP services that don't offer a JSON endpoint.
The XML Datasource module loads data from any XML feed (RSS, Atom, or custom XML) and automatically converts it to JSON for use with the list framework. This makes it possible to display RSS blog feeds, Atom news feeds, legacy XML APIs, or SOAP service responses as interactive, filterable lists — without any backend code.
Like the JSON datasource, the XML datasource is client-side: the data is fetched once, converted to JSON in the browser, and all filtering, sorting, and searching happen locally.
Configuration
|
Field |
Type |
Description |
|---|---|---|
|
Name |
Text |
A unique identifier for this datasource (e.g. |
|
URL |
URL |
The XML endpoint. Can be an external URL or a HubSpot file. CORS must be enabled on the server, and the response must be valid XML. |
|
JSON Query |
Text |
A JSONata expression applied to the converted JSON to extract the items array. The conversion produces a specific JSON structure (described below), and your query navigates it. |
Advanced Options
|
Field |
Description |
|---|---|
|
Search Fields |
JSONata expression returning an array of field values to search through. Example: |
|
Test Data |
Paste raw XML here to test your configuration without hitting the actual feed. The module will convert it to JSON and apply your JSON Query, letting you experiment with the structure. |
How It Works
-
The module fetches the XML from the URL as a raw string.
-
A built-in XML-to-JSON converter parses the XML and transforms it into a JSON object tree.
-
The JSON Query is applied to the resulting JSON to extract the items array.
-
From this point, the data behaves identically to the JSON datasource — filtering, sorting, searching, and paging all happen client-side.
XML-to-JSON Conversion Rules
Understanding the conversion rules is important for writing correct JSON Queries. The converter transforms XML elements using these rules:
-
Element names become the
nameproperty of the JSON object. -
Text-only child elements are promoted to direct key-value pairs on the parent object.
-
Attributes become key-value pairs in an
attributesobject. -
Complex child elements (those with their own children) go into a
childrenarray. -
Text content of a complex element becomes the
contentproperty.
Example: Simple XML
This XML:
<item>
<title>My Article</title>
<link>https://example.com/article</link>
<description>A great article about things.</description>
<pubDate>Mon, 15 Jan 2024 10:30:00 GMT</pubDate>
</item>
Becomes this JSON:
{
"name": "item",
"title": "My Article",
"link": "https://example.com/article",
"description": "A great article about things.",
"pubDate": "Mon, 15 Jan 2024 10:30:00 GMT"
}
Because <title>, <link>, <description>, and <pubDate> only contain text (no nested elements), they become direct properties on the parent object. This is the most common case and makes the converted JSON easy to work with.
Example: XML with Attributes
<item id="42" featured="true">
<title>Featured Article</title>
</item>
Becomes:
{
"name": "item",
"attributes": { "id": "42", "featured": "true" },
"title": "Featured Article"
}
Access attributes via attributes.id or attributes.featured in your renderer expressions.
Example: Complex Nested XML
<rss version="2.0">
<channel>
<title>My Blog</title>
<item>
<title>First Post</title>
<link>https://example.com/first</link>
</item>
<item>
<title>Second Post</title>
<link>https://example.com/second</link>
</item>
</channel>
</rss>
The <channel> has both text-only children (<title>) and complex children (<item> elements). The converted JSON uses both direct properties and the children array:
{
"name": "rss",
"children": [{
"name": "channel",
"title": "My Blog",
"children": [
{ "name": "item", "title": "First Post", "link": "https://example.com/first" },
{ "name": "item", "title": "Second Post", "link": "https://example.com/second"}
]
}]
}
Example: RSS Feed
The standard RSS 2.0 structure is <rss><channel><item>.... To extract the items:
Name: blog_feed
URL: https://example.com/blog/rss.xml
JSON Query: children[name='channel'].children[name='item']
Step by step:
1. children — access the root <rss> element’s children (which is the <channel>)
2. [name='channel'] — filter to the element named “channel”
3. .children — access the channel’s children (which includes <item> elements and other elements like <title>, <link>, <description>)
4. [name='item'] — filter to only the elements named “item”
Each resulting item has properties like title, link, description, and pubDate that you can reference in your renderer.
Example: Atom Feed
Atom feeds use a slightly different structure:
Name: news_feed
URL: https://example.com/feed/atom
JSON Query: children[name='entry']
Atom entries typically have title, summary, link (in attributes), and updated fields.
Example: Custom XML API
For a proprietary XML API:
Name: products_xml
URL: https://api.example.com/products.xml
JSON Query: children[name='product']
When to Use XML vs JSON
Use the XML datasource when: - The data source only provides XML (RSS feeds, legacy APIs, SOAP services, XML file exports). - You’re integrating with a system that has an XML export but no JSON API.
For everything else, prefer the JSON datasource. JSON is simpler to work with, has better browser support, and the JSONata query language was designed specifically for JSON data. If an API offers both XML and JSON endpoints, always choose JSON.
Debugging XML Conversion
If you’re unsure about the converted JSON structure, use the Test Data field:
1. Paste a sample of your XML into the Test Data field.
2. Preview the page with debug mode enabled (?hsDebug=true).
3. Check the browser console for the “Available JSONata placeholders” output — it shows the exact field paths available after conversion.
This is especially helpful for complex XML with mixed content, namespaces, or unusual nesting.