-1

使用 simpleXML,您如何显示提要的内容。我的意思是实际上在页面上显示 XML 以便我可以看到架构?

4

2 回答 2

0

In my example i will use XML file like:

<?xml version="1.0" encoding="UTF-8"?>
<module>
    <name>Menus</name>
    <folder>menus</folder>
    <install>install.php</install>
</module>

You can use to load xml file in a variable:

$mod = simplexml_load_file($XMLfile);

and call fields:

echo $mod->module->name;
echo $mod->module->folder;
echo $mod->module->install;

Hope this helps.

于 2013-04-25T18:01:21.943 回答
0
$xml = simplexml_load_file("URL GOES HERE");
echo "<pre>";
print_r($xml);
echo "</pre>";

Will print a readable array of the object.

And a VALID RSS feed has this schema:

foreach($xml->channel->item as $items){
  $title = $items->title;
  $link = $items->link;
  $description = $items->description;
  $pubDate = strtotime($items->pubDate);
  $pubDate = date('Y-m-d H:i:s', $pubDate);
}

Along with a few other attributes.

于 2013-04-25T18:02:08.297 回答