Recently I am using php to deal with a xml file.
But I don't know how to add a 'break' in my code.
The link is : http://babystory.diandian.com/rss
I want to use php to get the article named '[x]快乐王子'.But "foreach()" give me the last article named '[1]狼和七只小山羊'.
I want to add a break in "foreach()" so that I can get the article I want.
Here is my php code:
<?php
$xml = simplexml_load_file("http://babystory.diandian.com/rss");
foreach($xml->children() as $child){}
foreach($child->children() as $child2)
foreach($child2->children() as $child3)
{
$element = $child3->getName();
if($element=='title')
{
echo "<h1>" . $child3 . "</h1>";
}
if($element=='description')
{
echo $child3;
}
}
?>
Could you help me to edit my code.Thank you very much.