Lists Home |
Date Index |
- From: Ronald Bourret <firstname.lastname@example.org>
- To: "'email@example.com'" <firstname.lastname@example.org>
- Date: Thu, 12 Aug 1999 16:23:13 +0200
> I want to get the information kept between html tags or attributes.
> How do I do this using EXPAT or using SAX?
> How to extract INFO1 and INFO2 and store it in some other file.
Presumably, you mean XHTML or XML? Expat and other XML parsers won't work
on non-well-formed HTML documents, which is most.
In SAX, implement the DocumentHandler interface and register your
implementation with a SAX-enabled parser. When the parser calls
startElement(), you'll need to keep the element name (TEXT1 or TEXT2) as
state. You can also retrieve attribute values at this time (they are passed
to startElement). The parser will call characters() to pass you the text.
Based on the state (TEXT1 or TEXT2), you can store it appropriately. Note
that the parser can make multiple calls to characters() -- that is, it
could call characters() five times (once for each character), once (with
all the characters), or anything in between.
-- Ron Bourret
xml-dev: A list for W3C XML Developers. To post, mailto:email@example.com
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:firstname.lastname@example.org the following message;
To subscribe to the digests, mailto:email@example.com the following message;
List coordinator, Henry Rzepa (mailto:firstname.lastname@example.org)