frankperez87/xml2array
最新稳定版本:v1.0.0
Composer 安装命令:
composer require frankperez87/xml2array
包简介
This will convert a Simple XML string to a associative array.
README 文档
README
This package allows you to easily convert a xml string to a associative array.
Example Usage
<?php // Load in the composer autoloader file require 'vendor/autoload.php'; // Sample XML String $xml = '<?xml version="1.0" encoding="UTF-8"?> <urlset> <url> <loc>http://www.google.com</loc> <changefreq>monthly</changefreq> <priority>1</priority> </url> <url> <loc>http://www.yahoo.com</loc> <changefreq>monthly</changefreq> <priority>1</priority> </url> <url> <loc>http://www.bing.com</loc> <changefreq>monthly</changefreq> <priority>1</priority> </url> </urlset>'; // Pass in XML String $parser = new XML2Array\Parser($xml); // Convert XML to Associative Array $output = $parser->toArray(); // Print out results print '<pre>'; print_r($output); print '</pre>';
Example Output
Array ( [url] => Array ( [0] => Array ( [loc] => http://www.google.com [changefreq] => monthly [priority] => 1 ) [1] => Array ( [loc] => http://www.yahoo.com [changefreq] => monthly [priority] => 1 ) [2] => Array ( [loc] => http://www.bing.com [changefreq] => monthly [priority] => 1 ) ) )
统计信息
- 总下载量: 1.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-04