[1] => SimpleXMLElement Object
(
[orig] => A balloon floated across the sky.
[trans] => 气球飘过天空。
)
[2] => SimpleXMLElement Object
(
[orig] => A bolt of lightning lit up the sky.
[trans] => (一道)闪电照亮了天空。
)
[3] => SimpleXMLElement Object
(
[orig] => A bright moving object appeared in the sky at sunset.
[trans] => 日落西山时,天空出现了一个移动的发亮物体。
)
[4] => SimpleXMLElement Object
(
[orig] => A bright rainbow arched above.
[trans] => 一弯明亮的彩虹悬挂在天空。
)
)
)
“第二部分”将输出:
复制代码 代码如下:
例句:The church tower stood against the sky like a finger pointing towards heaven.
翻译:教堂的尖塔在天空的映衬下宛如指向天空的手指。
例句:A balloon floated across the sky.
翻译:气球飘过天空。
例句:A bolt of lightning lit up the sky.
翻译:(一道)闪电照亮了天空。
例句:A bright moving object appeared in the sky at sunset.
翻译:日落西山时,天空出现了一个移动的发亮物体。
例句:A bright rainbow arched above.
翻译:一弯明亮的彩虹悬挂在天空。
例子,更深入的一个遍历输出生成表格,代码如下:
复制代码 代码如下:
eader("content-type:text/html; charset=utf-8"); //设置编码
$xml = simplexml_load_file('a.xml'); //载入xml文件 $lists和xml文件的根节点是一样的
echo $xml->company."<br>";
echo $xml->town."<br>id:";
echo $xml->town['id']."<br>parent:";
echo $xml->town['parent']."<br>";
echo "<br>循环读取:<br>";
foreach($xml->user as $users){ //有多个user,取得的是数组,循环输出
echo "-------------------<br>";
echo "姓名:".$users->name."<br>";
echo "编号:".$users->age."<br>";
echo "性别:".$users->age['sex']."<br>";
echo "序号:".$users->height."<br>";
}
echo "<br>循环读取:<br>";
foreach($xml->town as $towns){ //有多个user,取得的是数组,循环输出
echo "-------------------<br>";
echo "id:".$towns['id']."<br>";
echo "归属:".$towns['parent']."<br>";
echo "地区:".$towns."<br>";
}