[SR-Users] parse XML nested name-spaces
Artur Hovsepyan
hvspa at yahoo.com
Wed Apr 6 18:13:09 CEST 2022
good evening everyone,
can you please help how to parse following XML body and get the "<gml:pos>31.204359 -44.512358</gml:pos>" in a variable?
<?xml version="1.0"?>
<presence xmlns="urn:ietf:params:xml:ns:pidf" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10" xmlns:gml="http://www.opengis.net/gml" xmlns:gs="http://www.opengis.net/pidflo/1.0" xmlns:con="urn:ietf:params:xml:ns:geopriv:conf" entity="sip:+6478897789 at ims.mnc0xx.mccxxx.3gppnetwork.org">
<dm:device id="Wifi">
<gp:geopriv>
<gp:location-info>
<gs:Circle srsName="urn:ogc:def:crs:EPSG::5524">
<gml:pos>31.204359 -44.512358</gml:pos>
<gs:radius uom="urn:ogc:def:uom:EPSG::8190">10.578000</gs:radius>
</gs:Circle>
<con:confidence pdf="normal">92</con:confidence>
</gp:location-info>
<gp:method>DBH_HELO</gp:method>
<gp:usage-rules/>
</gp:geopriv>
<dm:timestamp>2022-04-05T19:16:34Z</dm:timestamp>
</dm:device>
</presence>
i tried few variants:
xinfo("GML_LOC: $xml(x=>xpath:/pidf:presence/pidf:dm:device/pidf:gp:geopriv/pidf:gp:location-info/pidf:gs:Circle/pidf:gml:pos)\n")
xinfo("GML_LOC: $xml(x=>xpath:/pidf:presence/pidf:dm\:device/pidf:gp\:geopriv/pidf:gp\:location-info/pidf:gs\:Circle/pidf:gml\:pos)\n");
xinfo("GML_LOC: $xml(x=>xpath:/pidf:presence/pidf:dm:device/pidf:gp:geopriv/pidf:gp:location-info/pidf:gs:Circle/pidf:gml:pos)\n");
xinfo("GML_LOC: $xml(x=>xpath:/pidf:presence/dm:device/gp:geopriv/gp:location-info/gs:Circle/gml:pos)\n");
and end up with error "unable to evaluate xpath expression":
ERROR: xmlops [pv_xml.c:308]: pv_get_xml(): unable to evaluate xpath expression [/pidf:presence/dm:device/gp:geopriv/gp:location-info/gs:Circle/gml:pos/70]
thanks in advance,Art
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220406/741f60fc/attachment.htm>
More information about the sr-users
mailing list