Re: SOLUTION: Final version of news reader.
| From: | Web Master | Date: | Thu, 30 Nov 2000 17:01:17 +0000 |
| Subject: | Re: SOLUTION: Final version of news reader. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28076@lists.php.net to get a copy of this message | ||
Just curious, wouldn't it be easier to do it with a XML parser? (I am not a XML
person)
Jesus Climent wrote:
> How to read news from a file with the format:
>
> <noticia>
> Title|other_data_for_your_information
> text
> text
> more_text
> <end>
> <noticia>
> _same-format_
> <end>
>
> the open_table() , titulo() , fin() and close_table() are just functions
> to control the table structure.
>
> Thanks for you help.
>
> daTa
>
> <?
> function read_news() {
>
> $filename = "./noticias.data";
> $contents = file ($filename);
>
> open_table();
>
> $lines = count($contents);
>
> for ($j = 0; $j < $lines ; $j++) {
> if ($contents[$j] == "<noticia>\n") {
> print("$contents[$j]");
> $not_done = 1;
> for ($line = 1; $not_done; $line++) {
> if (($contents[$j + $line] == "<noticia>\n") || ($line > $lines)) {
> $not_done = 0;
> } else {
> $good_line = $contents[$j + $line];
> $datos = explode("|", $good_line);
> titulo($datos[0]);
> $body = 1;
> for ($line = $line+1 ; $body; $line++) {
> if (ereg("<end>", $contents[$j + $line])) {
> $body=0;
> } else {
> $body_text = $contents[$j + $line];
> print("$body_text");
> }
> }
> fin();
> $not_done = 0;
> }
> }
> }
> }
> close_table();
> }
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net