我正在尝试回显<head_1 data="Superhero"/>
中引号之间的文本
XML文件看起来像:
<?xml version="1.0"?>
<nowplaying version="1.1">
<playing_now>
<rbds_text data="SUPERHERO by Family Force 5"/>
<result>
<type data="song"/>
<head_1 data="Superhero"/>
<head_2 data="Family Force 5"/>
<head_url data="song/Family_Force_5/Superhero.html"/>
<foot_1 data="III.V - EP"/>
<foot_2 data="Family Force 5"/>
<foot_url data="album/Family_Force_5/III.V_-_EP.html"/>
<image_50 data="/images/music/thumbs/familyforce5-iiivep.jpg"/>
<image_200 data="/images/music/familyforce5-iiivep.jpg"/>
</result>
</playing_now>
</nowplaying>
我当前的PHP文件看起来像这样,但我得到了一个错误:
<?php
include 'playing-now/api.html';
$nowplaying = new SimpleXMLElement($xmlstr);
echo $nowplaying->playing_now->result->head_1;"
?>
echo $nowplaying->playing_now->result->head_1['data'];
如果你有任何错误,可能是在名字上。你应该能够像这样逃离他们:
echo $nowplaying->{'playing_now'}->result->{'head_1'}['data'];