示例#1
0
文件: XmlTest.php 项目: eleme/easyxml
 public function testStructure()
 {
     $data = array('foo' => array('bar' => array('a' => 'b', 'c' => 'd')));
     $structure = '<?xml version="1.0" encoding="utf-8"?>';
     $string = '<?xml version="1.0" encoding="utf-8"?><foo><bar><a>b</a><c>d</c></bar></foo>';
     $this->assertEquals($string, array_2_xml($data, $structure));
 }
示例#2
0
文件: xml.php 项目: eleme/easyxml
<?php

require __DIR__ . '/../vendor/autoload.php';
$array = array('abc' => array('cba' => 'abc', 'abc' => ''));
echo array_2_xml($array), "\n";
$structure = '<?xml version="1.0" encoding="utf-8"?>';
echo array_2_xml($array, $structure), "\n";
$json = '{"abc":{"cba":"abc","abc":""}}';
echo json_2_xml($json), "\n";
$structure = '<?xml version="1.0" encoding="utf-8"?>';
echo json_2_xml($json, $structure), "\n";
$xml = '<?xml version="1.0"?><abc><cba>abc</cba><abc/></abc>';
echo var_export(xml_2_array($xml)), "\n";
echo xml_2_json($xml), "\n";