[OpenSIPS-Users] How to parse XML Body?
xaled
xaled at web.de
Fri Jan 6 10:44:39 EST 2017
Hi Bogdan,
can you give any hints on how to get the Coordinates values and not the whole xml body from the regex subst?
Sorry for being not clever enough to figure it out myself.
Thanks
Hi Bogdan,
$var(reg) = "/gml:Coordinates>(.*)<\/gml:Coordinates/\1/";
xlog("Position is $(rb[1]{re.subst,$var(reg)})\n");
DBG:core:subst_run:matched shows the needed XML element with value, but not the value alone. The xlog output shows the whole XML body without gml:Coordinates.
2017-01-05T13:23:23.104982+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:tr_eval_re: Trying to apply reg
exp [/gml:Coordinates>(.*)<\/gml:Coordinates/\1/] on : [<?xml version="1.0" encoding="UTF-8"?>#015#012<presence xml
ns="urn:ietf:params:xml:ns:pidf" xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10" xmlns:gml="urn:opengis:specificat
ion:gml:schema-xsd:feature:v3.0" entity="pres:sip:+1234567 at test.com">#015#012 <tuple id="PDT">#015#012 <s
tatus>#015#012 <gp:geopriv>#015#012 <gp:location-info>#015#012 <gml:location>#015#012 <gml:Point gml:
id="point1" srsName="epsg:4346">#015#012 <gml:Coordinates>12.32 34.24</gml:Coordinates>#015#012 </gml:P
oint>#015#012 </gml:location>#015#012 </gp:location-info>#015#012 <gp:usage-rules>#015#012 <gp:retran
smission-allowed>no</gp:retransmission-allowed>#015#012 <gp:retention-expiry />#015#012 </gp:usage-rules>#01
5#012 </gp:geopriv>#015#012 </status>#015#012 <timestamp>2016-8-02T04:13:23Z</timestamp>#015#012 </tuple>#015#0
12</presence>#015#012#015#012]
2017-01-05T13:23:23.107376+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:tr_eval_re: we must compile the
regexp
2017-01-05T13:23:23.107903+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:subst_parser: ok, se is 0x7f39a
5d0a1f0
2017-01-05T13:23:23.108241+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:subst_run: running. r=0
2017-01-05T13:23:23.111918+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:subst_run: matched (404, 45): [
gml:Coordinates>12.32 34.24</gml:Coordinates]
2017-01-05T13:23:23.112380+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:buf_init: initializing...
2017-01-05T13:23:23.112730+01:00 ivr01 /usr/local/sbin/opensips[2227]: Position is <?xml version="1.0" encoding
="UTF-8"?>#015#012<presence xmlns="urn:ietf:params:xml:ns:pidf" xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10" xm
lns:gml="urn:opengis:specification:gml:schema-xsd:feature:v3.0" entity="pres:sip:+1234567 at test.com">#015#0
12 <tuple id="PDT">#015#012 <status>#015#012 <gp:geopriv>#015#012 <gp:location-info>#015#012 <gml:locatio
n>#015#012 <gml:Point gml:id="point1" srsName="epsg:4346">#015#012 <12.32 34.24>#015#012 </gml:Poi
nt>#015#012 </gml:location>#015#012 </gp:location-info>#015#012 <gp:usage-rules>#015#012 <gp:retransm
ission-allowed>no</gp:retransmission-allowed>#015#012 <gp:retention-expiry />#015#012 </gp:usage-rules>#015#
012 </gp:geopriv>#015#012 </status>#015#012 <timestamp>2016-8-02T04:13:23Z</timestamp>#015#012 </tuple>#015#012
</presence>
Thanks
From: Bogdan-Andrei Iancu [mailto:bogdan at opensips.org]
Sent: Donnerstag, 5. Januar 2017 13:12
To: OpenSIPS users mailling list <users at lists.opensips.org <mailto:users at lists.opensips.org> >; xaled <xaled at web.de <mailto:xaled at web.de> >
Subject: Re: [OpenSIPS-Users] How to parse XML Body?
Try $var(reg) = "/gml:Coordinates>(.*)<\/gml:Coordinates/\1/";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170106/630a5493/attachment.html>
More information about the Users
mailing list