最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

探討如何使用SimpleXML函數(shù)來加載和解析XML文檔

 更新時間:2013年06月07日 12:05:22   作者:  
本篇文章是對使用SimpleXML函數(shù)來加載和解析XML文檔進行了詳細的分析介紹,需要的朋友參考下
大量SmipleXML函數(shù)可用來加載和解析大量XML文檔。
--------------------------------------------------------------------------------
1.simpleXML_load_file()函數(shù)來加載指定的XML文件到對象。如果加載文件時遇到問題,則返回FLASE。例:
book.xml文件:
復(fù)制代碼 代碼如下:

<?xml version="1.0" standalone="yes"?>
<library>
 <book>
  <title>Pride and Prejudice</title>
  <author gender="female">Jane Austen</author>
  <description>Jane Austen's most popular work.</description>
 </book>
 <book>
  <title>The Conformist</title>
  <author gender="male">Alberto Moravia</author>
  <description>Alberto Moravia's classic psyhcological novel.</description>
 </book>
 <book>
  <title>The Sun Also Rises</title>
  <author gender="male">Ernest Hemingway</author>
  <description>The masterpiece that launched Hemingway's career.</description>
 </book>
</library>

php文件:
復(fù)制代碼 代碼如下:

<?php
$xml=simplexml_load_file("book.xml");echo "<pre>";
var_dump($xml);
?>

輸出結(jié)果:
復(fù)制代碼 代碼如下:

object(SimpleXMLElement)#1 (1) {
  ["book"]=>
  array(3) {
    [0]=>
    object(SimpleXMLElement)#2 (3) {
      ["title"]=>
      string(19) "Pride and Prejudice"
      ["author"]=>
      string(11) "Jane Austen"
      ["description"]=>
      string(32) "Jane Austen's most popular work."
    }
    [1]=>
    object(SimpleXMLElement)#3 (3) {
      ["title"]=>
      string(14) "The Conformist"
      ["author"]=>
      string(15) "Alberto Moravia"
      ["description"]=>
      string(46) "Alberto Moravia's classic psyhcological novel."
    }
    [2]=>
    object(SimpleXMLElement)#4 (3) {
      ["title"]=>
      string(18) "The Sun Also Rises"
      ["author"]=>
      string(16) "Ernest Hemingway"
      ["description"]=>
      string(49) "The masterpiece that launched Hemingway's career."
    }
  }
}

相關(guān)文章

最新評論

惠州市| 正阳县| 邵武市| 萝北县| 新竹市| 辛集市| 玛纳斯县| 长白| 开封市| 广平县| 德钦县| 梅河口市| 阿图什市| 珲春市| 武定县| 集贤县| 信丰县| 彭山县| 县级市| 子洲县| 阿克陶县| 温宿县| 和林格尔县| 同德县| 历史| 邢台市| 龙陵县| 达尔| 乌鲁木齐市| 东台市| 凤山县| 张家界市| 仪陇县| 太和县| 定陶县| 龙游县| 定襄县| 宜兰县| 油尖旺区| 集安市| 松溪县|