[reSIProcate] XML parser

Mateus Bellomo mateusbellomo at gmail.com
Sun Jul 10 20:50:38 CDT 2016


I'm trying to walk through the xml that I have and I couldn't get the value
of a certain tag. This is the xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<presence xmlns="urn:ietf:params:xml:ns:pidf"
xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" entity="
sip:mateusruivo at ekiga.net">
  <dm:person id="p6311">
    <rpid:activities/>
  </dm:person>
  <tuple id="t5763">
    <status>
      <basic>open</basic>
    </status>
    <contact>sip:mateusruivo at ekiga.net</contact>
    <note>Online</note>
  </tuple>
</presence>

When I get to <contact> I try to do a getValue() [1] but I'm getting an
empty string. I also didn't understand the implementation of this function:
why it is getting the value only of leaf nodes? what if the node I want to
get the value is not a leaf?

I also tried to use pidf parse [2] like this:

   ParseBuffer pb(notifyData.data(), notifyData.size());
   NameAddr res;
   res.parse(pb);

But I'm getting an error:

DEBUG | 20160710-224736.679 | telepathy-resiprocate | RESIP |
140593923626752 | ParseBuffer.cxx:971 | ParseBuffer.cxx:735, Parse failed
Expected a digit in context:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<presence xmlns="urn:ietf:params:xml:ns:pidf"
xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" entity="
sip:mateusruivo at ekiga.net">[CRLF]
                          ^[CRLF]
  <dm:person id="p6311">
    <rpid:activities/>
  </dm:person>
  <tuple id="t5763">
    <status>
      <basic>open</basic>
    </status>
    <contact>sip:mateusruivo at ekiga.net</contact>
    <note>Online</note>
  </tuple>
</presence>

Any help would be greatly appreciated.

[1]
https://github.com/resiprocate/resiprocate/blob/master/rutil/XMLCursor.cxx#L410
[2]
https://github.com/resiprocate/resiprocate/blob/master/resip/stack/Pidf.cxx#L171

2016-07-10 17:46 GMT-03:00 Mateus Bellomo <mateusbellomo at gmail.com>:

> Hello,
>
> I'm implementing the onNotifyReceived() method of
> resip/recon/UserAgent.cxx and for that I need to parse a XML that comes
> within the NOTIFY message.
>
> I'm reading the XMLCursos.* [1] class and I see that I could use that to
> do the parse. But I'm looking if it isn't already a parser into resiprocate
> library before I start to implement it.
>
> I saw the parse() method at [2] and it looks like it does the parse that I
> want but I didn't saw any usage of it in a XML, just in some string at
> resip/stack/test/testParserCategories.cxx.
>
> Thanks in advance.
>
>
> [1]
> https://github.com/resiprocate/resiprocate/blob/master/rutil/XMLCursor.cxx
> [2]
> https://github.com/resiprocate/resiprocate/blob/master/resip/stack/Pidf.cxx#L171
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20160710/cdb4b8f6/attachment.htm>


More information about the resiprocate-devel mailing list