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 = “
Link to this section Summary
Link to this section Functions
Defines the element that will be extracted
Options
:as
, :value
, :with
, module
See the “Shared options” section at the module documentation for more info.