PHP _construct() 函數
實例
函數創建一個新的 SimpleXMLElement 對象,然后輸出 body 節點的內容:
?php
$note=XML
note>
to>Tove/to>
from>Jani/from>
heading>Reminder/heading>
body>Don't forget me this weekend!/body>
/note>
XML;
$xml=new SimpleXMLElement($note);
echo $xml->body;
?>
[運行實例»](/try/showphp.php?filename=demo_func_simplexml_construct)
定義和用法
_construct()
函數創建一個新的 SimpleXMLElement 對象。
語法
_construct( _data,options,data_is_url,ns,is_prefix_ );


假設我們有如下的 XML 文件,"note.xml":
?xml version="1.0" encoding="ISO-8859-1"?>
note>
to>Tove/to>
from>Jani/from>
heading>Reminder/heading>
body>Don't forget me this weekend!/body>
/note>
實例 1
從 URL 中創建一個 SimpleXMLElement 對象:
?php
$xml=new SimpleXMLElement("note.xml",NULL,TRUE);
echo $xml->asXML();
?>
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內容請查看下面相關鏈接
您可能感興趣的文章:- PHP count()函數講解
- PHP getDocNamespaces()函數講解
- PHP getName()函數講解
- PHP getNamespaces()函數講解
- PHP registerXPathNamespace()函數講解
- PHP children()函數講解
- PHP attributes()函數講解
- PHP asXML()函數講解
- PHP addAttribute()函數講解
- PHP simplexml_import_dom()函數講解