Home >Backend Development >PHP Tutorial >Example of simple processing of XML data in PHP

Example of simple processing of XML data in PHP

巴扎黑
巴扎黑Original
2017-08-13 14:37:181377browse

This article mainly introduces PHP's simple method of processing XML data, and analyzes PHP's simple loading, reading, output and other operating techniques for XML format data based on specific examples. Friends who need it can refer to it

The example in this article describes how PHP simply processes XML data. Share it with everyone for your reference, the details are as follows:

Convert XML into an object and directly call the attributes inside


##

<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don&#39;t forget me this weekend!</body>
</note>
XML;
$xml=simplexml_load_string($note);
echo $xml->to . "<br>";
echo $xml->from . "<br>";
echo $xml->heading . "<br>";
echo $xml->body;
?>

Running results:


Tove
Jani
Reminder
Don&#39;t forget me this weekend!

The above is the detailed content of Example of simple processing of XML data in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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