[OpenSIPS-Users] Use of colon in XML element names
xaled
xaled at web.de
Sun Aug 20 12:08:55 EDT 2017
Hi,
Just tried the new xml module and have some issues with colon in element names. Should I use some escape magic for colons with opensips xml module?
Another question is how to add encoding="UTF-8" to have it like this - <?xml version="1.0" encoding="UTF-8"?>
It would be also great to have formatted XML output. Something like format parameter in toString method of XML::LibXML::Document in perl.
test:/usr/local/etc/opensips # /usr/local/sbin/opensips -V
version: opensips 2.3.1 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, F_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
git revision: 72fa146
main.c compiled on 18:53:05 Aug 16 2017 with gcc 4.8
$xml(xml_s) = "<tns:messageType></tns:messageType>";
$xml(xml_s.attr/xmlns:tns) = "http://test.org/abc/params/xml/abc";
$xml(xml_s/tns:messageType) = "<tns:crtg></tns:crtg>";
$xml(xml_s/tns:messageType/tns:crtg) = "<tns:ControlIndicators></tns:ControlIndicators>";
$xml(xml_s/tns:messageType/tns:crtg/tns:ControlIndicators) = "<tns:Factor>5</tns:Factor>";
xlog("XML_TEST: $xml(xml_s)\n");
2017-08-20T17:46:38.320273+02:00 test /usr/local/sbin/opensips[32422]: XML_TEST: <?xml version="1.0"?>#012<messageType/>
The final XML should be like this:
<?xml version="1.0" encoding="UTF-8"?>
<tns:messageType xmlns:tns="http://test.org/abc/params/xml/abc">
<tns:crtg>
<tns:ControlIndicators>
<tns:Factor>5</tns:Factor>
</tns:ControlIndicators>
</tns:crtg>
</tns:messageType>
Thanks,
xaled
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170820/44285014/attachment.html>
More information about the Users
mailing list