【发布时间】:2020-07-20 20:48:51
【问题描述】:
我有下一个代码:
<form method="POST">
<?php
echo "<select value>";
$xml = new SimpleXMLElement("http://news.google.com/news?ned=us&topic=h&output=rss",null,true);
foreach($xml->channel->item as $news)
{
echo "<option value='".$news->title."'>" . $news->title . "</option>";
}
echo "</select>";
?>
</form>
所以我有一个带有新闻标题的下拉框,当我选择一个标题时,我想显示 xml 文件中的描述,但我不知道该怎么做,如果有人可以帮助我,请
【问题讨论】:
-
你最好用 xpath 做一些事情来找到相应的故事——比如
//item[title="optionSelected"] -
在我看来你必须使用 jquery。例如。 jQuery.parseXML()