如何在php中将xml转换为html
问题描述:
<?xml version="1.0" encoding="UTF-8" ?><table>
<id title="161"> <name>sdffd</name> <q>3232</q> <price>323</price> </id>
<id title="162"> <name>sapana</name> <q>12312</q> <price>456123</price> </id>
<id title="163"> <name>sdsd</name> <q>ewe</q> <price>qwq</price> </id>
<id title="164"> <name>GDGFD</name> <q>323</q> <price>445</price> </id>
<id title="165"> <name>dsds</name> <q>32323</q> <price>2323</price> </id>
<id title="166"> <name>ewewq</name> <q>121</q> <price>3232</price> </id>
</table>
我有这个xml文件,我想用这种类型的外观在html中迷恋
表
id 161名称sdffd q 3232价格323
id 162名称sdffd q 12312价格456123
我在php中使用这种类型的代码
i have this xml file i want to convet in html WITH THIS type look
Table
id 161 name sdffd q 3232 price 323
id 162 name sdffd q 12312 price 456123
i use this type code in php
<?php
include("config.php");
$xml = simplexml_load_file("results.xml");
echo $xml->getname()."<br/>";
foreach($xml->children() as $child)
{
echo $xml->body[0]->attributes();
echo $child->getName() . ": " . $child . "<br />";
}
?>
wich显示类似
的东西
桌子
id
id
id
id
请告诉我解决方案
wich is show something like
table
id
id
id
id
pls tell me solution
答
xml = simplexml_load_file(" 回声
xml = simplexml_load_file("results.xml"); echo
xml- > getname()." br/ > ; foreach(
xml->getname()."<br/>"; foreach(
xml-> children()as
xml->children() as