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
In reply to Getting headlines from NewsML by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |