[OpenSIPS-Users] How to parse XML Body?

Bogdan-Andrei Iancu bogdan at opensips.org
Thu Jan 5 07:11:49 EST 2017


Try  $var(reg) = "/gml:Coordinates>(.*)<\/gml:Coordinates/\1/";

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 05.01.2017 13:38, xaled wrote:
>
> Hi Bogdan,
>
> Well - almost enough ;)
>
> $var(reg) = "/gml:Coordinates>(.*)<//gml:Coordinates/\1/";
>
> xlog("Position is $(rb[1]{re.subst,$var(reg)})\n");
>
> 2017-01-05T12:28:34.923153+01:00 ivr01 
> /usr/local/sbin/opensips[32257]: ERROR:core:subst_parser: unknown flag 
> m in /gml:Coordinates>(.*)<//gml:Coordinates/\1/
>
> 2017-01-05T12:28:34.923507+01:00 ivr01 
> /usr/local/sbin/opensips[32257]: ERROR:core:tr_eval_re: Can't compile 
> regexp
>
> Thanks
>
> *From:*Users [mailto:users-bounces at lists.opensips.org] *On Behalf Of 
> *xaled
> *Sent:* Donnerstag, 5. Januar 2017 12:22
> *To:* 'OpenSIPS users mailling list' <users at lists.opensips.org>
> *Subject:* Re: [OpenSIPS-Users] How to parse XML Body?
>
> Hi Bogdan,
>
> that is enough for me!
>
> Thanks.
>
> *From:*Bogdan-Andrei Iancu [mailto:bogdan at opensips.org]
> *Sent:* Donnerstag, 5. Januar 2017 12:19
> *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?
>
> You can use the $(rb[n]) to access a specific body part. see:
> http://www.opensips.org/Documentation/Script-CoreVar-2-2#toc65
>
> Once you get the XML body, you can use some regexp in order to extract 
> the needed info from the the XML (unfortunately thers is no way to 
> parse XML at script level). See the "re" transformation :
> http://www.opensips.org/Documentation/Script-Tran-2-2#toc82
>
>   $var(reg) = "/gml:pos>(.*)<//gml:pos/\1/";
>   xlog("Position is $(rb[0]{re.subst,$var(reg)})\n");
>
> Regards,
>
> Bogdan-Andrei Iancu
> OpenSIPS Founder and Developer
> http://www.opensips-solutions.com
>
> On 05.01.2017 12:57, xaled wrote:
>
>     Hi Bogdan;
>
>     opensips-2.2.2
>
>     Thanks.
>
>     *From:*Bogdan-Andrei Iancu [mailto:bogdan at opensips.org]
>     *Sent:* Donnerstag, 5. Januar 2017 11:39
>     *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?
>
>     Hi,
>
>     What version of OpenSIPS are you using ?
>
>     Regards,
>
>     Bogdan-Andrei Iancu
>
>     OpenSIPS Founder and Developer
>
>     http://www.opensips-solutions.com
>
>     On 04.01.2017 21:19, xaled wrote:
>
>         Hi,
>
>         What is the best way to parse xml body in an INVITE request?
>
>         I want to access geographic location information
>         gml:Coordinates or gml:pos from xml body and do some routing.
>         I’ve seen the emergency module, but it is too specific to be
>         useful in my basic scenario.
>
>         Content-Type: multipart/mixed;boundary=ssboundary-1_
>
>         Content-Type: application/pidf+xml
>
>>
>         <gml:Coordinates>XYZ</gml:Coordinates>
>
>         <gml:pos>XYZ</gml:pos>
>
>>
>
>
>
>         _______________________________________________
>
>         Users mailing list
>
>         Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>
>         http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>
>     _______________________________________________
>
>     Users mailing list
>
>     Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>
>     http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170105/e9b588d0/attachment-0001.html>


More information about the Users mailing list