使用PHP SimpleXML解析XML提要,一次只显示一个结果,结果之间有30秒的延迟。

The data comes from a XML feed that I need to parse using SimpleXML.

I want to display only one entry result at a time with a 30 second delay in between results.

Display example would be:

Title: 1

Id: 1

Then 30 seconds later

Title: 2

Id: 2

And so on.

Here is my code example:

$str = <<<XML
<feed>
    <entry>
        <title>Title 1</title>
        <id>1</id>
    </entry>
    <entry>
        <title>Title 2</title>
        <id>2</id>
    </entry>
    <entry>
        <title>Title 3</title>
        <id>3</id>
    </entry>
</feed>
XML;

$xml = new SimpleXMLElement($str);

foreach ($xml->entry as $entry) {
    echo "Title: ".$entry->title."<br/>";
    echo "Id: ".$entry->id."<br/>";
}

Right now this code outputs everything in the XML file:

Title: 1

Id: 1

Title: 2

Id: 2

Title: 3

Id: 3

How can I display the first entry for 30 seconds then have the second entry display in place of the first entry. This would continue until the end of the XML file and then start over again.

Any help would be appreciated. Thanks.