Home >Backend Development >PHP Tutorial >Use of simplexml_load_file function in php_PHP tutorial
例子
XML 文件:
代码如下 | |||||
PHP 代码:
if (file_exists('test.xml')) else 输出: object(SimpleXMLElement)#1 (4) |
If there is a "iciba.xml" file, its content is as follows:
The code is as follows | |
$xmldata = simplexml_load_file("iciba.xml"); header("Content-Type: text/html; charset=UTF-8"); $listcount = count($xmldata->sent); for($i=0;$i<$listcount;$i++){ //Part 2 SimpleXMLElement Object [key] => sky [acceptation] => Array; Array; [1] => SimpleXMLElement Object [2] => SimpleXMLElement Object [3] => SimpleXMLElement Object [4] => SimpleXMLElement Object ) ) "Part 2" will output: |
Example: The church tower stood against the sky like a finger pointing towards heaven.
Translation: The church steeple looks like a finger pointing to the sky against the sky.
Example: A balloon floated across the sky.
Translation: Balloons float across the sky.
Example: A bolt of lightning lit up the sky.
Translation: (A) lightning lit up the sky.
Example: A bright moving object appeared in the sky at sunset.
Translation: At sunset, a moving shiny object appeared in the sky.
Example: A bright rainbow arched above.
Translation: A bright rainbow hangs in the sky.
Example, a more in-depth traversal output generation table
The code is as follows
|
|
||||
http://www.bkjia.com/PHPjc/733192.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/733192.htmlTechArticleExample XML file: The code is as follows?xml version=1.0 encoding=ISO-8859-1? note toGeorge/to fromJohn /from headingReminder/heading bodyDon't forget the meeting!/body /note PHP code: ... |