-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
31 lines (20 loc) · 703 Bytes
/
index.php
File metadata and controls
31 lines (20 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
//测试
include_once('XmlParser.php');
$xml = '<xml><ToUserName><![CDATA[ouBTyw4kExNwmAPdLazEIK35JX9A]]></ToUserName><FromUserName><![CDATA[gh_1e25e2fb8845]]></FromUserName><CreateTime><![CDATA[1474537107]]></CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[你好]]></Content></xml>';
$arr = XmlParser::xml2arr($xml);
$obj = XmlParser::xml2obj($xml);
$test_arr = array(
'name' => array(
'first' => 'hu',
'second' => 'yue'
),
'age' => 20
);
$test_obj->name->first = 'hu';
$test_obj->name->second = 'yue';
$test_obj->age = 20;
var_dump($arr);
var_dump($obj);
echo XmlParser::arr2xml($test_arr, true);
echo XmlParser::obj2xml($test_obj, true);