【发布时间】:2012-01-07 20:14:10
【问题描述】:
我目前正在使用 file_get_contents 来获取 xml。 它运行良好,当我使用正确的 MIME 类型 header('Content-type: text/xml') 显示 xml 时,我会得到类似这样的东西:
<?xml version="1.0" encoding="iso-8859-1" ?>
<tarification compagnie="banane" cle="laclef">
<gamme reference="equilibre-sante">
<tarif formule="f100">Xx.xx</tarif>
<tarif formule="f200">Xx.xx</tarif>
</gamme>
</tarification>
要将它用作对象,我使用 simplexml_load_string 但是当我 print_r 返回的对象时,我没有看到公式属性,我只看到这样的内容:
SimpleXMLElement Object
(
[@attributes] => Array
(
[compagnie] => banane
[cle] => laclef
)
[gamme] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[reference] => equilibre-sante
)
[tarif] => Array
(
[0] => Xx.xx
[1] => Xx.xx
)
)
)
)
我想获取公式属性,我已经测试过按照这个tutorial来做到这一点,但没有成功。
【问题讨论】: