如何在php中将xml转换为html [英] how to convert xml to html in php

查看:104
本文介绍了如何在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


这篇关于如何在php中将xml转换为html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆