You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Fauze Valério Polpeta <fa...@bry.com.br> on 2005/10/27 16:07:03 UTC
HELP - Parsing from buffer
Hi;
I'm trying to build a protocol where the PDUs (i.e. Protocol Data Units) are formatted in XML. However taking a look at XERCES-C++, I didnt find a way to parse a XML from a binary buffer ( I mean an array of bytes ). Looks like xerces only parses XML data that is placed in a file. Since my PDU are not files, but an buffer that is loaded through a socket connection, how do I parse this XML binary buffer? Do I need to write a file and after that parse it? Is that possible with DOM?
Best Regards
Fauze
Re: HELP - Parsing from buffer
Posted by Alberto Massari <am...@datadirect.com>.
Hi Fauze,
you should use MemBufferInputSource (have a look at the sample MemParse)
Alberto
At 12.07 27/10/2005 -0200, Fauze Valério Polpeta wrote:
>Hi;
>
>I'm trying to build a protocol where the PDUs
>(i.e. Protocol Data Units) are formatted in XML.
>However taking a look at XERCES-C++, I didnt
>find a way to parse a XML from a binary buffer (
>I mean an array of bytes ). Looks like xerces
>only parses XML data that is placed in a file.
>Since my PDU are not files, but an buffer that
>is loaded through a socket connection, how do I
>parse this XML binary buffer? Do I need to write
>a file and after that parse it? Is that possible with DOM?
>
>Best Regards
>
>Fauze
Re: HELP - Parsing from buffer
Posted by de...@oget.net.
> Hi;
>
> I'm trying to build a protocol where the PDUs (i.e. Protocol Data Units)
> are formatted in XML. However taking a look at XERCES-C++, I didnt find a
> way to parse a XML from a binary buffer ( I mean an array of bytes ).
> Looks like xerces only parses XML data that is placed in a file. Since my
> PDU are not files, but an buffer that is loaded through a socket
> connection, how do I parse this XML binary buffer? Do I need to write a
> file and after that parse it? Is that possible with DOM?
>
> Best Regards
>
> Fauze
May i suggest looking at
http://xml.apache.org/xerces-c/apiDocs/classInputSource.html
and
http://xml.apache.org/xerces-c/apiDocs/classMemBufInputSource.html
MemBufInputSource (const XMLByte *const srcDocBytes, const unsigned int
byteCount, const XMLCh *const bufId, const bool adoptBuffer=false,
MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
A memory buffer input source is constructed from a buffer of byte data,
and the count of bytes in that buffer.
Enjoy,
Laurent Oget