cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
According to the NewsML docs at SourceForge you do this by getting ahold of the NewsLines interface for the NewsComponent you are interested in. You then use method getHeadLineCount to get the number of headlines, then use method getHeadLine(index) to get a particular headline in the list.
My relevant bit of code to do this is
if (my $newslines = $newscomp->getNewsLines) { print " Headlines:\n"; my $headcount = $newslines->getHeadLineCount(); for my $i (0..$headcount-1) { print $newslines->getHeadLine($i),"\n"; } }
When I run this it throws an error on the print statement that says: "HeadLine can be a multi-element field: must call getHeadLineList at readstories.pl line 106"
I tried using the suggested method and retrieving the results into a list, like so:
my @headlines = $newslines->getHeadLineList(); foreach my $h (@headlines) { print $h->getHeadLine(),"\n"; }
But it doesn't seem to like that either. Can anyone tell me where I'm going wrong?
Tia...
Steve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting headlines from NewsML
by zentara (Cardinal) on Aug 27, 2005 at 11:08 UTC | |
by cormanaz (Deacon) on Aug 27, 2005 at 17:45 UTC |