Home > Backend Development > PHP Problem > How to convert xml into object in php

How to convert xml into object in php

王林
Release: 2023-03-13 11:18:02
Original
1973 people have browsed it

php method to convert xml into object: [$xml= "<xml><appid>123456</appid></xml>"; $objectxml = simplexml_load_string($xml);].

How to convert xml into object in php

The operating environment of this article: windows10 system, php 7, thinkpad t480 computer.

XML file

$xml= "<xml><appid>123456</appid></xml>";
Copy after login

Convert file to object

$objectxml = simplexml_load_string($xml);
Copy after login

Convert object to JSON

$xmljson= json_encode($objectxml );
Copy after login

Convert json to array

$xmlarray=json_decode($xmljson,true);
Copy after login

Recommended learning: php training

The above is the detailed content of How to convert xml into object in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template