Discussion: mutual conversion between array2xml, xml2array, and xml and array _ PHP
Source: Internet
Author: User
This article provides a detailed analysis of the mutual conversion between array2xml, xml2array, and xml and array. if you want to use php as a backend server, you will often encounter this situation, the xml file from the front-end needs to be parsed and the data is returned in xml format. in this case, the conversion of arrays associated with xml and php is very frequent. For example, this method is often used for interaction between flex and other client programs and servers. The following are two methods I have summarized, which greatly simplifies the workload of conversion between xml and arrays.
The code is as follows:
/**
*
* Convert a simple array to a simple xml
* @ Param string $ array of data to be converted
* @ Param string $ tag the tag to use
* @ Example
* $ Arr = array (
'Rtxaccount' => 'Aaron ', 'ipadd' => '2017. 168.0.12 ',
'Conferencelist' => array ('conference '=>
Array (
Array ('ferenceid' => 1212, 'ferencetitle' => 'quanshi 444 ', 'smeaccount' => 'http: // www.bitsCN.com '),
Array ('ferenceid' => 454, 'ferencetitle' => 'quanshi meetting ', 'smeaccount' => 'http: // www.bitsCN.com '),
Array ('ferenceid' => 6767, 'ferencetitle' => 'quanshi meetting ', 'smeaccount' => 'http: // www.bitsCN.com '),
Array ('ferenceid' => 232323, 'ferencetitle' => 'quanshi uuu ', 'smeaccount' => 'http: // www.bitsCN.com '),
Array ('ferenceid' => 8989, 'ferencetitle' => 'quanshi meetting ', 'smeaccount' => 'http: // www.bitsCN.com '),
Array ('ferenceid' => 1234343212, 'ferencetitle' => 'quanshi meetting ', 'smeaccount' => 'http: // www.bitsCN.com ')
)
)
);
Convert:
Aaron
192.168.0.12
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.