I am trying to use the SAXHandler (Pharo 1.2.1) to parse a delicious rss feed. I want to get the contents of a tag, i.e. the text that lies between the opening tag and the closing tag.
Thanks to Laurent's excellent video I understand how to access the attributes (using startElement:attributes:), but I can't work out how to get the intra-tag text. I am sure it is a simple call, but could someone point me in the right direction?
Cheers Andy
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On Sat, Apr 16, 2011 at 1:50 AM, Andy Burnett wrote:
> I am trying to use the SAXHandler (Pharo 1.2.1) to parse a delicious rss > feed. I want to get the contents of a tag I hope a guess does less harm than good. This example looks relevant: http://wiki.squeak.org:8080/squeak/505 unless the Pharo version of the code has changed greatly from the version used by the wiki writers. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Andy Burnett
Write a method
YourSAXParser>>characters: aString to access the contents of the current node in aString. YourSAXParser should be a subclass of SAXHandler. Cheers, 2011/4/15 Andy Burnett <[hidden email]>: > I am trying to use the SAXHandler (Pharo 1.2.1) to parse a delicious rss > feed. I want to get the contents of a tag, i.e. the text that lies between > the opening tag and the closing tag. > Thanks to Laurent's excellent video I understand how to access the > attributes (using startElement:attributes:), but I can't work out how to get > the intra-tag text. I am sure it is a simple call, but could someone point > me in the right direction? > Cheers > Andy > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > > -- Hernán Morales Information Technology Manager, Institute of Veterinary Genetics. National Scientific and Technical Research Council (CONICET). La Plata (1900), Buenos Aires, Argentina. Telephone: +54 (0221) 421-1799. Internal: 422 Fax: 425-7980 or 421-1799. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Andy Burnett
<< David Corking said..
> I am trying to use the SAXHandler (Pharo 1.2.1) to parse a delicious rss > feed. I want to get the contents of a tag I hope a guess does less harm than good. This example looks relevant: http://wiki.squeak.org:8080/squeak/505 unless the Pharo version of the code has changed greatly from the version used by the wiki writers.>> Thanks David, that is a really useful resource. Cheers
Andy
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Andy Burnett
hernan.morales said
<< Write a method YourSAXParser>>characters: aString to access the contents of the current node in aString. YourSAXParser should be a subclass of SAXHandler. >>
Thanks Hernan, I now have a working system.
Cheers
Andy
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
I don't know if this caution applies in Squeak, but in Java land, the SAX parsers don't guarantee that there is only one call to character for the text between the tags. That is, you can't set aString directly, you have to build up the response in case there are multiple calls to the character method.
On Tue, Apr 19, 2011 at 1:50 PM, Andy Burnett <[hidden email]> wrote: hernan.morales said _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |