I have an XML file like this:
<rss version="2.0">
<channel>
-<title>Match Probabilities</title>
-<link>abc[dot]com</link>
-<description>abc.com RSS feed - match results and soccer predictions.</description>
-<item>
-<title>Manchester City v Watford</title>
-<link>abc[dot]com/h2h/manchester-city-watford/</link>
-<pubDate>05/18/2019</pubDate>
-<description><a href="abc[dot]com/h2h/manchester-city-watford/" target="_blank">Manchester City v Watford</a><br/><br/><table border="1" width="100%"><tr><td width="40%"><strong>Result prediction</strong></td> <td>Manchester City to win</td></tr><tr><td><strong>Over/Under prediction</strong></td><td>over 2.5 goals</td></tr><tr><td><strong>HT / FT prediction</strong></td><td>draw / Manchester City to win</td></tr><tr><td><strong>Goal Difference prediction</strong></td><td>2 goals</td></tr><tr><td><strong>Total Goals prediction</strong></td><td>6 goals</td></tr><tr><td><strong>Team to Score prediction</strong></td><td>both teams</td></tr><tr><td><strong>Team to Win without Conceding a Goal prediction</strong></td><td>none</td></tr><tr><td><strong>Anytime Goalscorer prediction</strong></td><td>S. Agüero(Manchester City)<br/>Gabriel Jesus(Manchester City)<br/>P. Foden(Manchester City)<br/></td></tr></table><br/>
</description>
</item>
</channel>
</rss>
I have tried this code, and I did succeed in outputting the string.
$xml = simplexml_load_file(file.xml);
foreach($xml->channel->item as $item){
$html .= $item->description;
$html .= "<hr />";
}
echo $html;
However, my expectation is that I just want to get the table
in the description
attribute only.
I have also tried $html .= $item->description->table->Attribute('<tr>';
//line 7, but I failed. the error message looked like this:
Fatal error: Call to undefined method SimpleXMLElement::Attribute() in /home/content/12/1232354/html/views/file.html on line 7.
Your help will be appreciated. Thanks