PHP code example of hedeqiang / xml

1. Go to this page and download the library: Download hedeqiang/xml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hedeqiang / xml example snippets




use Hedeqiang\Xml\Xml;

$xml = "<xml>
        <foo>name</foo>
        <bar>age</bar>
        <name><![CDATA[text here]]></name>
    </xml>";
print_r(xml::parse($xml)) ;

$data = [
    'id' => 'bk101',
    'author' => 'Gambardella, Matthew',
    'title' => 'XML Developer\'s Guide',
    'genre' => 'Computer',
    'price' => '44.95',
    'items' => ['foo', 'bar'],
    'publish_date' => '2000-10-01',
    'description' => 'An in-depth look at creating applications with XML.',
];
print_r(xml::build($data));