View Source exml_query (exml v3.3.4)
Summary
Functions
Query attribute value by name. Returns the attribute value associated with
Name
if Element
contains such attribute. Otherwise returns undefined
Query attribute value by name. Returns the attribute value associated with
Name
if Element
contains such attribute. Otherwise returns Default
See also: attr/2.
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
gets the elements/attrs/cdatas reachable by the described path
See also: path/2.
Types
-type element_with_attr_of_value() :: {element_with_attr, binary(), binary()}.
-type element_with_name_and_ns() :: {element_with_ns, binary(), binary()}.
-type element_with_ns() :: {element_with_ns, binary()}.
-type path() :: [cdata | {element, binary()} | {attr, binary()} | element_with_ns() | element_with_name_and_ns() | element_with_attr_of_value()].
Functions
-spec attr(exml:element(), binary()) -> binary() | undefined.
Name
if Element
contains such attribute. Otherwise returns undefined
-spec attr(exml:element(), binary(), Other) -> binary() | Other.
Name
if Element
contains such attribute. Otherwise returns Default
See also: attr/2.
-spec cdata(exml:element()) -> binary().
-spec path(exml:element(), 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">>
-spec path(exml:element(), path(), Other) -> exml:element() | binary() | Other.
path/2
but returns the given Default
if no element matches the path.See also: path/2.
-spec paths(exml:element(), path()) -> [exml:element() | binary()].
See also: path/2.
-spec subelement(exml:element(), binary()) -> exml:element() | undefined.
-spec subelement(exml:element(), binary(), Other) -> exml:element() | Other.
-spec subelement_with_attr(exml:element(), AttrName :: binary(), AttrValue :: binary()) -> exml:element() | undefined.
-spec subelement_with_attr(Element, AttrName, AttrValue, Other) -> SubElement | Other when Element :: exml:element(), AttrName :: binary(), AttrValue :: binary(), SubElement :: exml:element(), Other :: term().
-spec subelement_with_name_and_ns(exml:element(), binary(), binary()) -> exml:element() | undefined.
-spec subelement_with_name_and_ns(exml:element(), binary(), binary(), Other) -> exml:element() | Other.
-spec subelement_with_ns(exml:element(), binary()) -> exml:element() | undefined.
-spec subelement_with_ns(exml:element(), binary(), Other) -> exml:element() | Other.
-spec subelements(exml:element(), binary()) -> [exml:element()].
-spec subelements_with_attr(exml:element(), binary(), binary()) -> [exml:element()].
-spec subelements_with_name_and_ns(exml:element(), binary(), binary()) -> [exml:element()].
-spec subelements_with_ns(exml:element(), binary()) -> [exml:element()].