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自动注册登录验证机制实现代码

php自动注册登录验证机制实现代码

背景: 在phpwind站点后台添加一个名为“广告管家”(广告管家为CNZZ的一款广告投放的应用)的应用,整个“广告管家”的应用是通过iframe载入,载入的具体内容根据不同站点显示针对...

php如何连接sql server

php如何连接sql server

说明:   1:PHP5.2.x本身有个php_mssql.dll的扩展用来连接Sql server,但是这个dll只是用来连接低版本 Sql server的(2000以下版本),在Sq...

PHP中header和session_start前不能有输出原因分析

在http传输文本中,规定必须 header和content顺序必须是:header在前content在后,并且header的格式必须满足“keyword: value\n”这种格式。...

PHP array_multisort()函数的使用札记

函数  bool array_multisort ( array &$arr [, mixed $arg = SORT_ASC [, mixed $arg = SORT_REGULAR...

PHP使用preg_split()分割特殊字符(元字符等)的方法分析

本文实例讲述了PHP使用preg_split()分割特殊字符(元字符等)的方法。分享给大家供大家参考,具体如下: 这里所说的特殊字符就是正则中使用的特殊字符,如: | . + 等 其它的...