Capuli v0.1.0 Capuli View Source

Capuli parses xml files through a DSL defined in a module, this module will be the parser. Use element if you want to fetch one tag and elements for multiple tags.

Here is a parser for an Atom entry:

defmodule AtomEntry do
  use Capuli

  element :title
  element :description
  element :link, as: :url, value: :href, with: [
    type: "text/html"
  ]
  elements :images
end

You can use the AtomEntry inside other parsers as well:

defmodule Atom do
  use Capuli

  element :link
  elements :entry, as: :entries, module: AtomEntry
end

Element(s) Options

  • :as - the key used for setting the name of the element

  • :value - retrieves the value from an specific attribute, it takes the value from the tag by default

  • :with - search tags with specific attributes, the tag must have all attributes

  • :module - used for parsing the extracted value

Capuli sets a parse method that is used for processing the xml:

xml = “…..“ Atom.parse(xml)

Link to this section Summary

Functions

Defines the element that will be extracted

Defines the element that will be extracted

Link to this section Functions

Link to this macro element(name, opts \\ []) View Source (macro)

Defines the element that will be extracted

Options

:as, :value, :with, module

See the “Shared options” section at the module documentation for more info.

Link to this macro elements(name, opts \\ []) View Source (macro)

Defines the element that will be extracted

Options

:as, :value, :with, module

See the “Shared options” section at the module documentation for more info.