SimpleXML 函数 业 ,精于勤 荒于嬉.

SimpleXML 函数 simplexml_import_dom Get a SimpleXMLElement object from a DOM node

发表日期:2021-07-01 08:57:25 | 来源: | 分类:SimpleXML 函数

      示例1
<?php 
$dom = new DOMDocument;
$dom->loadXML('<books><book><title>blah</title></book></books>');
if (!$dom) {
    echo 'Error while parsing the document';
    exit;
}
$s = simplexml_import_dom($dom);
echo $s->book[0]->title;
?>

阅读全文 »

SimpleXML 函数 simplexml_load_file Interprets an XML file into an object

发表日期:2021-07-01 08:57:25 | 来源: | 分类:SimpleXML 函数

      示例1
<?php 
// The file test.xml contains an XML document with a root element// and at least an element /[root]/title.if (file_exists('test.xml')) {
    $xml = simplexml_load_file('test.xml');
     print_r($xml);
}
 else {
    exit('Failed to open test.xml.');
}
?>

阅读全文 »

SimpleXML 函数 simplexml_load_string Interprets a string of XML into an object

发表日期:2021-07-01 08:57:25 | 来源: | 分类:SimpleXML 函数

      示例1
<?php 
$string = <<<XML<?xml version='1.0'?> <document> <title>Forty What?</title> <from>Joe</from> <to>Jane</to> <body>  I know that's the answer -- but what's the question? </body></document>XML;
$xml = simplexml_load_string($string);
print_r($xml);
?>

阅读全文 »

全部博文(1580)
集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。