Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: How do I parse values from a RSS feed?
Charles Stricklin wrote:
> If I have an RSS newsfeed like this:
[...]
> And the following code is used to parse that file/feed:
[...]
>     /* ...open the feed and parse it... */
>     $fp = @fopen($feed, 'rb');
>     if (is_resource($fp)) {
>         xml_parse_into_struct( $xml_parser, $fp, $vals, $index );
>     }
>     @fclose($fp);

Read the manual closely and you will notice that the second argument of
xml_parse_into_struct() should be a string, not a resource.

The following would work better:

$file = file_get_contents($feed);

if ($file) {
xml_parse_into_struct( $xml_parser, $file, $vals, $index );
}

> How do I extract the values from $xml_parser?

Again, when you read the manual, you will notice that you don't extract the
values from the resource stored in $xml_parser, but that
xml_parse_into_struct() uses the last two arguments to create an array of
keys and values and an array of indexes which matches the positions of the
elements in the document.

Check the output of print_r() on both arrays to see what I mean.

Please read http://www.php.net/manual/en/ref.xml.php for more info and
examples.


JW




Report this thread to moderator Post Follow-up to this message
Old Post
Janwillem Borleffs
09-22-04 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:15 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.