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 Markus Heller <ma...@relix.de> on 2005/12/20 04:52:17 UTC

a little help from my friends...

Dear List,

I would like to write a parser that gives me a tuple on each node: the path to 
a node and the pcdata, the container text. I managed to assemble the path 
information by recursively calling startElement from an instantiated 
defaultHandler. 

Though, now I would like to retrieve all that's in the container and I don't 
know how to do it best. Ideally, I would like to have the container contents 
together with the path information. 

How proceed?

Thanks a lot!

Markus


Re: a little help from my friends...

Posted by Axel Weiß <aw...@informatik.hu-berlin.de>.
Markus Heller schrieb:
> Dear List,
>
> I would like to write a parser that gives me a tuple on each node: the
> path to a node and the pcdata, the container text. I managed to
> assemble the path information by recursively calling startElement from
> an instantiated defaultHandler.
>
> Though, now I would like to retrieve all that's in the container and I
> don't know how to do it best. Ideally, I would like to have the
> container contents together with the path information.
>
> How proceed?

Hi Markus,

since you want to retrieve all the information of a xml file, I'd suggest 
to use a DOM parser and walk through the DOM tree.

			Axel


Re: a little help from my friends...

Posted by Alberto Massari <am...@datadirect.com>.
At 06.08 20/12/2005 +0100, Markus Heller wrote:
>Dear List,
>
> > I would like to write a parser that gives me a tuple on each node: the path
> > to a node and the pcdata, the container text. I managed to assemble the
> > path information by recursively calling startElement from an instantiated
> > defaultHandler.
> >
> > Though, now I would like to retrieve all that's in the container and I
> > don't know how to do it best. Ideally, I would like to have the container
> > contents together with the path information.
> >
> > How proceed?
>Well, It seems I had an idea... There is that wonderful "characters" member
>function in defaultHandler, respectively ContentHandler:
>
>I have now tried it out, but the chars variable only gives me numbers instead
>of chars:
>
>(Quote from the documentation:)
>void ContentHandler::characters   (   const XMLCh *const    chars,
>   const unsigned int   length
>   )
>
>I'm absolutely convinced that some of you know what I'm talking 
>about. Can you
>give me a hint?

Hi Markus,
the "chars" variable contains the data, but encoded in UTF-16 (i.e. 
unsigned short). You can use XMLString::transcode to convert it to 
the local code page of your system.

Alberto 



Re: a little help from my friends...

Posted by Markus Heller <ma...@relix.de>.
Dear List,

> I would like to write a parser that gives me a tuple on each node: the path
> to a node and the pcdata, the container text. I managed to assemble the
> path information by recursively calling startElement from an instantiated
> defaultHandler.
>
> Though, now I would like to retrieve all that's in the container and I
> don't know how to do it best. Ideally, I would like to have the container
> contents together with the path information.
>
> How proceed?
Well, It seems I had an idea... There is that wonderful "characters" member 
function in defaultHandler, respectively ContentHandler:

I have now tried it out, but the chars variable only gives me numbers instead 
of chars:

(Quote from the documentation:)
void ContentHandler::characters   (   const XMLCh *const    chars, 
  const unsigned int   length
  )

I'm absolutely convinced that some of you know what I'm talking about. Can you 
give me a hint?

Thanks in advance,
Markus