[Expat-discuss] extracting value other than element and attribute

Nick MacDonald nickmacd at gmail.com
Tue Jul 22 14:57:22 CEST 2008


To get the start and the end of the elements, you use callbacks, which
in my code are called startElement and endElement:
        XML_SetElementHandler(parser, startElement, endElement);
This is also where you get to know the parameters on the elements,
such as your id="1001"

But to get the data inside the elements, you need the following, which
calls a callback elementText in my case:
        XML_SetCharacterDataHandler(parser, elementText);

void XMLCALL elementText(
  void*       userData,
  const char*  text,
  int          len
);

NOTE you may get more than one of these callbacks, and YOU have to
handle the concatenation.  (This can occur depending on line breaks,
and special embedded content, such as &  and the like.  I mention
this, as it has been a stumbling block and often seems to surprise
others who write to the list about it.)

Good luck,
  Nick


On Tue, Jul 22, 2008 at 1:56 AM, yuki latt <yuki.latt at gmail.com> wrote:
>      I gave up using expat-win-32 on windows. :(
>
>     Now I am using expat linux version on cygwin (OS: windows XP).
> Everything is OK. Please let me ask a question.
>
> Outline.c prints  elements and their arguments.  Let's say that there is -
> <date id="001"> 2008-7-22 </date>.
>
> Outline.c prints -   date and  id="1001" (element and its arguments).
>
>                          I want to retreive the  value 2008-7-22.  How
> should I do?


More information about the Expat-discuss mailing list