php使用simplexml_load_file加载XML文件并显示XML的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了php使用simplexml_load_file加载XML文件并显示XML的方法。分享给大家供大家参考。具体实现方法如下:

<?php
  $xml = simplexml_load_file("sample.xml");
  echo htmlspecialchars($xml->asXML());
?>

sample.xml文件内容如下

<library>
  <book>
   <title>A</title>
   <author gender="female">B</author>
   <description>C</description>
  </book>
  <book>
   <title>C</title>
   <author gender="male">D</author>
   <description>E</description>
  </book>
  <book>
   <title>F</title>
   <author gender="male">G</author>
   <description>H</description>
  </book>
</library>

希望本文所述对大家的php程序设计有所帮助。

相关文章

PHP strtotime函数详解

先看手册介绍: strtotime — 将任何英文文本的日期时间描述解析为 Unix 时间戳 格式:int strtotime ( string $time [, int $now ]...

Erlang的运算符(比较运算符,数值运算符,移位运算符,逻辑运算符)

Erlang的比较运算符 opDescription==等于/=不等于=<小于等于<小于>=大于等于>大于=:=精确的等于=/=精确的不等于等于和精确等于的区别:...

PHP动态创建Web站点的方法

PHP有4个用于使用外部函数的函数:include()、include_once()、require()和require_once(). 为了使用它们,PHP脚本中将包括如下代码行: i...

php算开始时间到过期时间的相隔的天数

复制代码 代码如下://mktime = mktime($hours,minute,seconds,month,day,years) $start_time = mktime(0,0,0...

php 生成WML页面方法详解

由于静态的WAP页面在很多方面不能满足用户个性化的服务请求,因此通过WAP服务器端语言产生动态的WML页面,具有很广泛的应用价值和很高的商业价值。   WAP应用结构非常类似于Inter...