<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
tt
{mso-style-priority:99;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle24
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle25
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle26
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle27
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=DE link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Hi Bogdan,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>works like a charm, thanks!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>As an additional bonus now I know how to work with the perl module ;)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>$rb(mime)[idx] is even more flexible.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='color:windowtext;mso-fareast-language:DE'>From:</span></b><span lang=EN-US style='color:windowtext;mso-fareast-language:DE'> Bogdan-Andrei Iancu [mailto:bogdan@opensips.org] <br><b>Sent:</b> Dienstag, 17. Januar 2017 15:12<br><b>To:</b> xaled <xaled@web.de>; 'OpenSIPS users mailling list' <users@lists.opensips.org><br><b>Subject:</b> Re: [OpenSIPS-Users] How to parse XML Body?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><tt><span style='font-size:10.0pt'>Hi,</span></tt><span style='font-size:10.0pt;font-family:"Courier New"'><br><br><tt>There was a small typo in my regexp. The correct one is:</tt><br></span><br>$var(reg) = "/(.*)gml:Coordinates>(.*)<\/gml:Coordinates(.*)/\2/s";<br>xlog("Position is $(rb[1]{re.subst,$var(reg)})\n");<br><br>I tried it and it does the job. <br><br>Regarding the usability of the $rb variable, yes you have a point. I was thinking of something like $rb(mime)[idx] to access also per mime.<br><br>Best regards,<br><br><br><span style='font-size:12.0pt;mso-fareast-language:DE'><o:p></o:p></span></p><pre>Bogdan-Andrei Iancu<o:p></o:p></pre><pre>OpenSIPS Founder and Developer<o:p></o:p></pre><pre><a href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a><o:p></o:p></pre><div><p class=MsoNormal>On 01/13/2017 12:04 PM, xaled wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='color:#1F497D'>Hi Bogdan,</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>thank you for looking at this issue. This regex does not work. I tried different combinations of the idea but it just not getting there. </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-13T11:02:42.287766+01:00 ivr01 /usr/local/sbin/opensips[24845]: DBG:core:tr_eval_re: we must compile the regexp</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-13T11:02:42.288116+01:00 ivr01 /usr/local/sbin/opensips[24845]: WARNING:core:parse_repl: \/ unknown escape in (.*)<\/gml:Coordinates(.*)/\2/s</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-13T11:02:42.288464+01:00 ivr01 /usr/local/sbin/opensips[24845]: ERROR:core:subst_parser: unknown flag . in (.*)/gml:Coordinates>(.*)<\/gml:Coordin</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>ates(.*)/\2/s</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-13T11:02:42.288787+01:00 ivr01 /usr/local/sbin/opensips[24845]: ERROR:core:tr_eval_re: Can't compile regexp</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>I managed to get it running with perl:</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>use OpenSIPS qw ( log );</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>use OpenSIPS::Constants;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>use OpenSIPS::Message;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>sub parsePIDFLO {</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> my $m = shift;</span><o:p></o:p></p><p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-US style='color:#1F497D'>my $body = $m->getBody();</span><o:p></o:p></p><p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-US style='color:#1F497D'>($coord) = $body =~ /Coordinates>(.*)</;</span><o:p></o:p></p><p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-US style='color:#1F497D'>my ($long, $lat) = split( /\s+/, $coord );</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Btw it would be great to be able to address the xml body by something like this:</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>rb[application/pidf+xml] or rb["application/pidf+xml"] otherwise if bodies come in different order rb[1] would not work.</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Thanks</span><o:p></o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='color:windowtext;mso-fareast-language:DE'>From:</span></b><span lang=EN-US style='color:windowtext;mso-fareast-language:DE'> Bogdan-Andrei Iancu [<a href="mailto:bogdan@opensips.org">mailto:bogdan@opensips.org</a>] <br><b>Sent:</b> Mittwoch, 11. Januar 2017 11:05<br><b>To:</b> OpenSIPS users mailling list <a href="mailto:users@lists.opensips.org"><users@lists.opensips.org></a>; asd asd <a href="mailto:xaled@web.de"><xaled@web.de></a><br><b>Subject:</b> Re: [OpenSIPS-Users] How to parse XML Body?</span><o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Hi,<br><br>Please try<br><br>$var(reg) = "(.*)/gml:Coordinates>(.*)<\/gml:Coordinates(.*)/\2/s";<br>xlog("Position is $(rb[1]{re.subst,$var(reg)})\n");<br><br>Regards,<br><br><br><o:p></o:p></p><pre>Bogdan-Andrei Iancu<o:p></o:p></pre><pre>OpenSIPS Founder and Developer<o:p></o:p></pre><pre><a href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a><o:p></o:p></pre><div><p class=MsoNormal>On 01/06/2017 05:44 PM, xaled wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='color:#1F497D'>Hi Bogdan,</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>can you give any hints on how to get the Coordinates values and not the whole xml body from the regex subst?</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Sorry for being not clever enough to figure it out myself.</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Thanks </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Hi Bogdan, </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-US style='color:#1F497D'>$var(reg) = "/gml:Coordinates>(.*)<\/gml:Coordinates/\1/";</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US style='color:#1F497D'>xlog("Position is $(rb[1]{re.subst,$var(reg)})\n");</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>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. </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-05T13:23:23.104982+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:tr_eval_re: Trying to apply reg</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>exp [/gml:Coordinates>(.*)<\/gml:Coordinates/\1/] on : [<?xml version="1.0" encoding="UTF-8"?>#015#012<presence xml</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>ns="urn:ietf:params:xml:ns:pidf" xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10" xmlns:gml="urn:opengis:specificat</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>ion:gml:schema-xsd:feature:v3.0" entity=<a href="mailto:pres:sip:+1234567@test.com">"pres:sip:+1234567@test.com"</a>>#015#012 <tuple id="PDT">#015#012 <s</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>tatus>#015#012 <gp:geopriv>#015#012 <gp:location-info>#015#012 <gml:location>#015#012 <gml:Point gml:</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>id="point1" srsName="epsg:4346">#015#012 <gml:Coordinates>12.32 34.24</gml:Coordinates>#015#012 </gml:P</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>oint>#015#012 </gml:location>#015#012 </gp:location-info>#015#012 <gp:usage-rules>#015#012 <gp:retran</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>smission-allowed>no</gp:retransmission-allowed>#015#012 <gp:retention-expiry />#015#012 </gp:usage-rules>#01</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>5#012 </gp:geopriv>#015#012 </status>#015#012 <timestamp>2016-8-02T04:13:23Z</timestamp>#015#012 </tuple>#015#0</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>12</presence>#015#012#015#012]</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-05T13:23:23.107376+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:tr_eval_re: we must compile the</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>regexp</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-05T13:23:23.107903+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:subst_parser: ok, se is 0x7f39a</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>5d0a1f0</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-05T13:23:23.108241+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:subst_run: running. r=0</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-05T13:23:23.111918+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:subst_run: matched (404, 45): [</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>gml:Coordinates>12.32 34.24</gml:Coordinates]</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-05T13:23:23.112380+01:00 ivr01 /usr/local/sbin/opensips[2227]: DBG:core:buf_init: initializing...</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>2017-01-05T13:23:23.112730+01:00 ivr01 /usr/local/sbin/opensips[2227]: Position is <?xml version="1.0" encoding</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>="UTF-8"?>#015#012<presence xmlns="urn:ietf:params:xml:ns:pidf" xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10" xm</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>lns:gml="urn:opengis:specification:gml:schema-xsd:feature:v3.0" entity=<a href="mailto:pres:sip:+1234567@test.com">"pres:sip:+1234567@test.com"</a>>#015#0</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>12 <tuple id="PDT">#015#012 <status>#015#012 <gp:geopriv>#015#012 <gp:location-info>#015#012 <gml:locatio</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>n>#015#012 <gml:Point gml:id="point1" srsName="epsg:4346">#015#012 <12.32 34.24>#015#012 </gml:Poi</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>nt>#015#012 </gml:location>#015#012 </gp:location-info>#015#012 <gp:usage-rules>#015#012 <gp:retransm</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>ission-allowed>no</gp:retransmission-allowed>#015#012 <gp:retention-expiry />#015#012 </gp:usage-rules>#015#</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>012 </gp:geopriv>#015#012 </status>#015#012 <timestamp>2016-8-02T04:13:23Z</timestamp>#015#012 </tuple>#015#012</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'></presence></span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Thanks</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><o:p></o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='color:windowtext;mso-fareast-language:DE'>From:</span></b><span lang=EN-US style='color:windowtext;mso-fareast-language:DE'> Bogdan-Andrei Iancu [<a href="mailto:bogdan@opensips.org">mailto:bogdan@opensips.org</a>] <br><b>Sent:</b> Donnerstag, 5. Januar 2017 13:12<br><b>To:</b> OpenSIPS users mailling list <<a href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>>; xaled <<a href="mailto:xaled@web.de">xaled@web.de</a>><br><b>Subject:</b> Re: [OpenSIPS-Users] How to parse XML Body?</span><o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Try $var(reg) = "/gml:Coordinates>(.*)<\/gml:Coordinates/\1/";<br><br><br><br><o:p></o:p></p><p class=MsoNormal><span style='font-size:12.0pt'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:12.0pt'><br><br><br><br></span><o:p></o:p></p><pre>_______________________________________________<o:p></o:p></pre><pre>Users mailing list<o:p></o:p></pre><pre><a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><o:p></o:p></pre><pre><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></pre></blockquote><p class=MsoNormal><span style='font-size:12.0pt'> </span><o:p></o:p></p></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:DE'><o:p> </o:p></span></p></div></body></html>