SweetXml.parse

You're seeing just the function parse, go back to SweetXml module for more information.

Specs

parse(doc(), opts :: list()) :: xmlElement()

Parse a document into a form ready to be used by xpath/3 and xmap/2.

doc can be

  • a byte list (iodata)
  • a binary
  • any enumerable of binaries (for instance File.stream!/3 result)

options can be both:

  • xmerl's options as described on the xmerl_scan documentation page, see the erlang tutorial for some advanced usage. For example: parse(doc, quiet: true)
  • :dtd to prevent DTD parsing or fetching, with the following possibilities:
    • :none, will prevent both internal and external entities, it is the recommended options on untrusted XML;
    • :all, the default, for backward compatibility, allows all DTDs;
    • :internal_only, will block all attempt at external fetching;
    • [only: entities] where entities is either an atom for a single entity, or a list of atoms. If any other entity is defined in the XML, parse will raise on them.

When doc is an enumerable, the :cont_fun option cannot be given.

Returns an xmlElement record.