Origami.

domObject(dom)

This accepts as input a DOM structure such as that produced by htmlDom or xmlDom, or obtained by unpacking an XML file.

The function returns a plain object representation of the DOM input. A common reason for doing this is to apply a template to the data in the HTML or XML document.

  • If an element node contains only text nodes, the text will be returned as a text property of the element.
  • Runs of leading and trailing whitespace in text nodes is collapsed to a single space character.

Example: if feed.xml contains

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>#pondlife</title>
    <link>https://pondlife.netlify.app</link>
    <description>Dispatches from off the grid</description>
    <item>
      <title>Hello from the pond!</title>
      <link>https://pondlife.netlify.app/posts/2025-07-04.html</link>
      <guid>https://pondlife.netlify.app/posts/2025-07-04.html</guid>
    </item>
  </channel>
</rss>

then this file can be read (and implicitly unpacked) and passed to Origami.domObject:

$ ori Origami.domObject feed.xml
name: rss
attributes:
  version: "2.0"
children:
  - name: channel
    children:
      - name: title
        text: "#pondlife"
      - name: link
        text: https://pondlife.netlify.app
      - name: description
        text: Dispatches from off the grid
      - name: item
        children:
          - name: title
            text: Hello from the pond!
          - name: link
            text: https://pondlife.netlify.app/posts/2025-07-04.html
          - name: guid
            text: https://pondlife.netlify.app/posts/2025-07-04.html