123456"; $objectxml = simplexml_load_string($xml);]."/> 123456"; $objectxml = simplexml_load_string($xml);].">

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

How to convert xml into object in php

王林
王林Original
2021-10-18 16:59:391936browse

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>";

Convert file to object

$objectxml = simplexml_load_string($xml);

Convert object to JSON

$xmljson= json_encode($objectxml );

Convert json to array

$xmlarray=json_decode($xmljson,true);

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!

Statement:
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