Article - Talk xml
Return the list of ejabberd core modules
XML utilities (xml)
Various utilities to manipulate XML packets.
XML representation in ejabberd
Each XML stanza is represented with the following tuple:
XMLElement = {xmlelement, Name, Attrs, [ElementOrCDATA]}
Name = string()
Attrs = [Attr]
Attr = {Key, Val}
Key = string()
Val = string()
ElementOrCDATA = XMLElement | CDATA
CDATA = {xmlcdata, string()}
E.g. this stanza:
<message to='test@conference.example.org' type='groupchat'>
<body>test</body>
</message>
is represented as the following structure:
{xmlelement, "message",
[{"to", "test@conference.example.org"},
{"type", "groupchat"}],
[{xmlelement, "body",
[],
[{xmlcdata, "test"}]}]}}
API
element_to_string(El) -> string()El = XMLElementReturns string representation of XML stanzaEl.
* crypt(S) -> string()S = string()
Returns string which correspond to S with encoded XML special characters.
remove_cdata(ECList) -> EListECList = [ElementOrCDATA]
* EList = [XMLElement]
EList is a list of all non-CDATA elements of ECList.
get_path_s(El, Path) -> ResEl = XMLElementPath = [PathItem]
* PathItem = PathElem | PathAttr | PathCDATA
* PathElem = {elem, Name}
* PathAttr = {attr, Name}
* PathCDATA = cdata
* Name = string()
* Res = string() | XMLElement
If Path is empty, then returns El. Else sequentially consider elements of Path. Each element is one of:
- {elem, Name}: Name is the name of subelement of El, if such element exists, then this element is considered in following steps, else returns empty string.
- {attr, Name}: If El have attribute Name, then returns value of this attribute, else returns empty string.
- cdata: returns CDATA of El.
