Using SAX to get the contents of a node

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using SAX to get the contents of a node

Andy Burnett
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
Reply | Threaded
Open this post in threaded view
|

Re: Using SAX to get the contents of a node

dcorking
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
Reply | Threaded
Open this post in threaded view
|

Re: Using SAX to get the contents of a node

hernanmd
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
Reply | Threaded
Open this post in threaded view
|

Re: Using SAX to get the contents of a node

Andy Burnett
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
Reply | Threaded
Open this post in threaded view
|

Re: Using SAX to get the contents of a node

Andy Burnett
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
Reply | Threaded
Open this post in threaded view
|

Re: Using SAX to get the contents of a node

David Mitchell-10
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

<<
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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners