$xml = simplexml_load_file($URL);
foreach($xml->children() as $child)
{
foreach($child as $child)
{
$list[] = $child->getName();
}
}
<channel>
<title></title>
<link></link>
<description></description>
<item>
<title></title>
<link></link>
<description></description>
<pubDate></pubDate>
<guid isPermaLink="false"></guid>
<dc:date></dc:date>
<dc:maxQuantity></dc:maxQuantity>
</item>
<channel>
我得到了这样的答案标题链接描述发布日期,指导
我没有得到
DC:日期,直流:最大数量.,
如何获得这种类型的元素?请任何人帮助我。
您没有为 dc: 元素提供任何命名空间,但它可能与这里描述的内容
使用 PHP 的 DOMDocument。
$objDOM = new DOMDocument();
$objDOM->load("test.xml"); //make sure path is correct
$note = $objDOM->getElementsByTagName("lon");
// for each note tag, parse the document and get values for
// tasks and details tag.
foreach( $note as $value )
{
$tasks = $value->getElementsByTagName("id");
$task = $tasks->item(0)->nodeValue;
$details = $value->getElementsByTagName("name");
$detail = $details->item(0)->nodeValue;
$notes = $value->getElementsByTagName("notes");
$notes = $notes->item(0)->nodeValue;
echo "$task :: $detail :: $notes <br>";
}