Module exml_query

Easy navigation in XML trees.

Copyright © (C) 2011-2021, Erlang Solutions Ltd.

Description

Easy navigation in XML trees

Data Types

element_with_attr_of_value()

element_with_attr_of_value() = {element_with_attr, binary(), binary()}

element_with_name_and_ns()

element_with_name_and_ns() = {element_with_ns, binary(), binary()}

element_with_ns()

element_with_ns() = {element_with_ns, binary()}

path()

path() = [cdata | {element, binary()} | {attr, binary()} | element_with_ns() | element_with_name_and_ns() | element_with_attr_of_value()]

Function Index

attr/2Query attribute value by name.
attr/3Query attribute value by name.
cdata/1
path/2Gets the element/attr/cdata contained in the leftmost path Find an element in the xml tree by a path that is pattern-matched against such xml tree structure.
path/3Gets the element/attr/cdata in the leftmost possible described path.
paths/2gets the elements/attrs/cdatas reachable by the described path.
subelement/2
subelement/3
subelement_with_attr/3
subelement_with_attr/4
subelement_with_name_and_ns/3
subelement_with_name_and_ns/4
subelement_with_ns/2
subelement_with_ns/3
subelements/2
subelements_with_attr/3
subelements_with_name_and_ns/3
subelements_with_ns/2

Function Details

attr/2

attr(Element::exml:element(), Name::binary()) -> binary() | undefined

Query attribute value by name. Returns the attribute value associated with Name if Element contains such attribute. Otherwise returns undefined

attr/3

attr(Xmlel::exml:element(), Name::binary(), Other) -> binary() | Other

Query attribute value by name. Returns the attribute value associated with Name if Element contains such attribute. Otherwise returns Default

See also: attr/2.

cdata/1

cdata(Xmlel::exml:element()) -> binary()

path/2

path(Element::exml:element(), Path::path()) -> exml:element() | binary() | undefined

Gets the element/attr/cdata contained in the leftmost path Find an element in the xml tree by a path that is pattern-matched against such xml tree structure

For example, given an xml document like
  <message from='alice@localhost' to='alice@localhost/res1' id='id-1'>
    <result xmlns='urn:xmpp:mam:2' id='BGCH2R2950G1'>
      <forwarded xmlns='urn:xmpp:forward:0'>
        <delay xmlns='urn:xmpp:delay' stamp='2021-05-05T08:36:19Z' from='bob@localhost/res1'/>
        <message from='bob@localhost/res1' xmlns='jabber:client' xml:lang='en' to='alice@localhost/res1' type='chat'>
          <body>Message from bob to alice</body>
        </message>
      </forwarded>
    </result>
  </message>
The path
    [{element_with_ns, <<"result">>, <<"urn:xmpp:mam:2">>},
     {element_with_ns, <<"forwarded">>, <<"urn:xmpp:forward:0">>},
     {element_with_ns, <<"message">>, <<"jabber:client">>},
     {element, <<"body">>},
     cdata}],
would return <<"Message from bob to alice">>

path/3

path(Xmlel::exml:element(), Rest::path(), Other) -> exml:element() | binary() | Other

Gets the element/attr/cdata in the leftmost possible described path. Like path/2 but returns the given Default if no element matches the path.

See also: path/2.

paths/2

paths(Xmlel::exml:element(), Rest::path()) -> [exml:element() | binary()]

gets the elements/attrs/cdatas reachable by the described path

See also: path/2.

subelement/2

subelement(Element::exml:element(), Name::binary()) -> exml:element() | undefined

subelement/3

subelement(Xmlel::exml:element(), Name::binary(), Other) -> exml:element() | Other

subelement_with_attr/3

subelement_with_attr(Element::exml:element(), AttrName::binary(), AttrValue::binary()) -> exml:element() | undefined

subelement_with_attr/4

subelement_with_attr(Element, AttrName, AttrValue, Other) -> SubElement | Other

subelement_with_name_and_ns/3

subelement_with_name_and_ns(Element::exml:element(), Name::binary(), NS::binary()) -> exml:element() | undefined

subelement_with_name_and_ns/4

subelement_with_name_and_ns(Element::exml:element(), Name::binary(), NS::binary(), Other) -> exml:element() | Other

subelement_with_ns/2

subelement_with_ns(Element::exml:element(), NS::binary()) -> exml:element() | undefined

subelement_with_ns/3

subelement_with_ns(Xmlel::exml:element(), NS::binary(), Other) -> exml:element() | Other

subelements/2

subelements(Xmlel::exml:element(), Name::binary()) -> [exml:element()]

subelements_with_attr/3

subelements_with_attr(Xmlel::exml:element(), AttrName::binary(), Value::binary()) -> [exml:element()]

subelements_with_name_and_ns/3

subelements_with_name_and_ns(Xmlel::exml:element(), Name::binary(), NS::binary()) -> [exml:element()]

subelements_with_ns/2

subelements_with_ns(Xmlel::exml:element(), NS::binary()) -> [exml:element()]


Generated by EDoc