I’m exploring the possibility of parsing XML files in Zola using the built-in function load_data. From my tests, I have confirmed that it is possible to access XML elements using dot notation. However, I have not found a way to access attributes within those elements.
For context, I am working with OPML files. Here’s a simplified example of an OPML file:
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
<head>
<title>Sample OPML</title>
</head>
<body>
<outline text="Tech Blogs">
<outline text="Example Blog" type="rss" xmlUrl="https://example.com/rss.xml" htmlUrl="https://example.com"/>
</outline>
</body>
</opml>
Using load_data, I can access elements like opml.head.title or iterate over opml.body.outline. However, I haven’t found a way to extract attributes like xmlUrl or htmlUrl from the <outline> elements.
My questions
- Is there a way to access XML attributes using Tera/Zola’s built-in functions?
- If not, is this a current limitation of Tera, or is there a workaround available within Zola?
For reference, Hugo offers a built-in way to access XML attributes, as described in its documentation.