色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

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

大量SmipleXML函數(shù)可用來(lái)加載和解析大量XML文檔。
--------------------------------------------------------------------------------
1.simpleXML_load_file()函數(shù)來(lái)加載指定的XML文件到對(duì)象。如果加載文件時(shí)遇到問(wèn)題,則返回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."
    }
  }
}

php技術(shù)探討如何使用SimpleXML函數(shù)來(lái)加載和解析XML文檔,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 平遥县| 区。| 革吉县| 开原市| 贵溪市| 沙雅县| 东乡县| 嘉义县| 和林格尔县| 吴忠市| 莆田市| 平原县| 鹤壁市| 开阳县| 宜城市| 长子县| 南华县| 永顺县| 吕梁市| 綦江县| 五寨县| 巩义市| 黄大仙区| 宁远县| 辛集市| 西峡县| 丹寨县| 临安市| 昭觉县| 松江区| 长沙县| 兰考县| 闽侯县| 上高县| 庆安县| 奎屯市| 德庆县| 平和县| 石台县| 乡宁县| 三原县|