[Kamailio-Users] new feature: fine access to xml documents
Daniel-Constantin Mierla
miconda at gmail.com
Thu Jun 25 11:21:36 CEST 2009
Hello,
several days ago I committed support for accessing components of xml
documents using pseudo-variables based on XPath syntax. The new
$xml(...) PV is implemented in the presence_xml module as it works with
xml docs and links libxml2.
Short description in the cookbook:
https://sip-router.org/wiki/cookbooks/pseudo-variables/devel#presence_xml_pseudo-variables
As an example:
- publish has the body:
<?xml version='1.0' encoding='UTF-8'?>
<presence xmlns='urn:ietf:params:xml:ns:pidf'
xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model'
xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid'
xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='sip:daniel at asipto.com'>
<tuple id='t8b484917'>
<status><basic>open</basic></status>
</tuple>
<dm:person
id='p7562ef60'><rpid:activities><rpid:unknown/></rpid:activities></dm:person>
</presence>
Getting the presence status:
# this is needed because libxml2 cannot work with default no-prefix ns,
so we alias the "p" prefix.
modparam("presence_xml", "xml_ns", "p=urn:ietf:params:xml:ns:pidf")
$xml(a=>doc) = $rb;
$xml(a=>xpath:/p:presence/p:tuple/p:status/p:basic)
Next is to update the presence modules to be able to work with the
documents that have been updated in the config.
Comments, opinions and improvements are welcome!
Cheers,
Daniel
--
Daniel-Constantin Mierla
http://www.asipto.com/
More information about the Users
mailing list