good evening everyone, can you please help how to parse following XML body and get the "gml:pos31.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@ims.mnc0xx.mccxxx.3gppnetwork.org"> <dm:device id="Wifi"> gp:geopriv gp:location-info <gs:Circle srsName="urn:ogc:def:crs:EPSG::5524"> gml:pos31.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:methodDBH_HELO</gp:method> gp:usage-rules/ </gp:geopriv> dm:timestamp2022-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
iirc, to get the text between tags, you have to use text() function of xpath (should be in the xpath specs) -- I guess you have to use:
$xml(x=>xpath:/pidf:presence/dm:device/gp:geopriv/gp:location-info/gs:Circle/gml:pos/text())
Cheers, Daniel
On 06.04.22 18:13, Artur Hovsepyan wrote:
good evening everyone,
can you please help how to parse following XML body and get the "gml:pos31.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@ims.mnc0xx.mccxxx.3gppnetwork.org"> <dm:device id="Wifi"> gp:geopriv gp:location-info <gs:Circle srsName="urn:ogc:def:crs:EPSG::5524"> gml:pos31.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:methodDBH_HELO</gp:method> gp:usage-rules/ </gp:geopriv> dm:timestamp2022-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
Kamailio - Users Mailing List - Non Commercial Discussions
- sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
it still fails, i have tried handful scenarios, but still failing: 454 modparam("xmlops", "xml_ns", "rpid=urn:ietf:params:xml:ns:pidf:rpid") 455 modparam("xmlops", "xml_ns", "pidf=urn:ietf:params:xml:ns:pidf") 456 modparam("xmlops", "xml_ns", "gp=urn:ietf:params:xml:ns:pidf:geopriv10") 457 modparam("xmlops", "xml_ns", "dm=urn:ietf:params:xml:ns:pidf:data-model") 458 modparam("xmlops", "xml_ns", "gs=http://www.opengis.net/pidflo/1.0")
with the text() function, i am getting error: ERROR: <core> [core/pvapi.c:176]: pv_locate_name(): non-closing inner-name parenthesis [$xml(x=>xpath:/pidf:presence/dm:device/gp:geopriv/gp:location-info/gs:Circle/gml:pos/text()] without text, i am getting this: 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]
i am still stuck.
On Wednesday, April 6, 2022, 01:43:13 PM EDT, Daniel-Constantin Mierla miconda@gmail.com wrote:
iirc, to get the text between tags, you have to use text() function of xpath (should be in the xpath specs) -- I guess you have to use:
$xml(x=>xpath:/pidf:presence/dm:device/gp:geopriv/gp:location-info/gs:Circle/gml:pos/text())
Cheers, Daniel
On 06.04.22 18:13, Artur Hovsepyan wrote:
good evening everyone, can you please help how to parse following XML body and get the "gml:pos31.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@ims.mnc0xx.mccxxx.3gppnetwork.org"> <dm:device id="Wifi"> gp:geopriv gp:location-info <gs:Circle srsName="urn:ogc:def:crs:EPSG::5524"> gml:pos31.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:methodDBH_HELO</gp:method> gp:usage-rules/ </gp:geopriv> dm:timestamp2022-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
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions * sr-users@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users -- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - Online * https://www.asipto.com/sw/kamailio-advanced-training-online/