Origami.

xmlDom(xml)

Parses the given XML text and returns the resulting DOM structure.

When working with an XML file with a .xml extension, Origami will automatically unpack the file into DOM, so you wouldn’t need to apply this xmlDom function to the file. Rather, this function is useful when transforming XML obtained from other types of files.

Example: xmlDom can be used to process a .opml file into DOM. If blogs.opml contains:

<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
  <head>
    <title>
      Blogs using Web Origami
    </title>
  </head>
  <body>
    <outline
      type="rss"
      text="Jim Nielsen's Blog"
      htmlUrl="https://blog.jim-nielsen.com"
      xmlUrl="https://blog.jim-nielsen.com/feed.xml"
    />
    <outline
      type="rss"
      text="Posts and notes from Nick Simson"
      htmlUrl="https://www.nicksimson.com"
      xmlUrl="https://www.nicksimson.com/feed.xml"
    />
    <outline
      type="rss"
      text="Vale.Rocks Posts"
      htmlUrl="https://vale.rocks"
      xmlUrl="https://vale.rocks/posts/feed.xml"
    />
  </body>
</opml>

This can be converted to DOM via Origami.xmlDom, and then further converted to a plain JavaScript object via Origami.domObject:

$ ori Origami.domObject Origami.xmlDom blogs.opml
name: opml
attributes:
  version: "2.0"
children:
  - name: head
    children:
      - name: title
        text: Blogs using Web Origami
  - name: body
    children:
      - name: outline
        attributes:
          type: rss
          text: Jim Nielsen's Blog
          htmlUrl: https://blog.jim-nielsen.com
          xmlUrl: https://blog.jim-nielsen.com/feed.xml
      - name: outline
        attributes:
          type: rss
          text: Posts and notes from Nick Simson
          htmlUrl: https://www.nicksimson.com
          xmlUrl: https://www.nicksimson.com/feed.xml
      - name: outline
        attributes:
          type: rss
          text: Vale.Rocks Posts
          htmlUrl: https://vale.rocks
          xmlUrl: https://vale.rocks/posts/feed.xml