Hello,

On 12/6/10 3:13 PM, Andreas Granig wrote:
Hi,

I'm having troubles fetching an xpath from an xml document using
presence_xml, so I probably do something wrong (using kamailio 3.0.x):

$xml(x=>doc) = '<?xml version="1.0" encoding="utf-8"?><presence
xmlns="urn:ietf:params:xml:ns:pidf"
entity="sip:t...@mydomain.com"><tuple
id="86ae65b7-42de-4399-b635-295caad13aac"><status><basic>none</basic></status></tuple></presence>';

xlog("L_INFO", "all=$xml(x=>doc)\n");

  ->  prints the whole document, which is ok

xlog("L_INFO", "tmp1=$xml(x=>xpath:/)\n");

   ->  also prints the whole document (including the xml tag in the
beginning, not sure if this is ok)

xlog("L_INFO", "tmp2=$xml(x=>xpath:/presence)\n");

   ->  prints an empty string

How is this actually supposed to work? What I'd like to do in the end is
extracting for example the "none" from the "basic"-tag by specifying
"xpath:/presence/tuple/status/basic", which also returns an empty string
now, also when appended with "/text()".
the problem is in between IETF and XML guys :-)

xpath require to use a prefix for namespaces. The SIMPLE guys liked to set a default one without prefix.

For this case, try:

modparam("presence_xml", "xml_ns", "pidf=urn:ietf:params:xml:ns:pidf")

then:

xlog("L_INFO", 
"tmp2=$xml(x=>xpath:/pidf:presence/pidf:tuple/pidf:status/pidf:basic)\n");

- see which one is giving more convenient resultL with text() or no text()

There are some tricks I did for the xcap_server, because I think this is not scaling. There I just changed 'xmlns=' in 'xmlnx=' or so, so there is no namespace without prefix -- then your format for xpath works fine.

Cheers,
Daniel

--
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Jan 24-26, 2011, Irvine, CA, USA
http://www.asipto.com


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to