Detailed explanation of XML operations based on PHP

高洛峰
Release: 2016-12-24 11:24:59
Original
1664 people have browsed it

$xml = simplexml_load_file('example.xml'); //Create SimpleXML object
var_dump($xml); // Output XML
?>

$xml = simplexml_load_file ('example.xml');                                                                                                                                                                                                 echo "$a-> name
";                                                                                                                                                                                                                                                                                       ​ //Read XML file
echo $xml- >depart->name[0]; ml->depart-> children() as $depart)                                                                                                                                                                    . XML data
}
?>

$xml = simplexml_load_file('example.xml'); //Read XML file

$result = $xml->xpath('/departs/depart/employees/employee/name'); //Define nodes
var_dump($result ) ; 
$xml->depart->name[0] = "Human Resource"; " //Standardization XML data
?>

$xml = simplexml_load_file('example.xml'); //Read XML data
$newxml = $xml->asXML(); //Standardize XML data
$fp = fopen("newxml .xml", "w"); //Open the file to write XML data
fwrite($fp, $newxml); //Write XML data
fclose($fp);                                                                                                                                                             since

For more detailed explanations of XML operations based on PHP, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template