Lists Home |
Date Index |
- From: Ronald Bourret <email@example.com>
- To: "'firstname.lastname@example.org'" <email@example.com>
- 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:firstname.lastname@example.org
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:email@example.com the following message;
To subscribe to the digests, mailto:firstname.lastname@example.org the following message;
List coordinator, Henry Rzepa (mailto:email@example.com)