Home>Article>Backend Development> How to parse xml to array in php

How to parse xml to array in php

hzc
hzc Original
2020-06-05 14:38:05 2900browse

How to parse xml to array in phpphp

php parses xml and converts it into an array

php parses xml data and converts it into an array. Use simplexml_load_string() to convert the xml object, json_encode() to convert the object to json, and json_decode() to convert it to an array.

  • simplexml_load_file() Load xml url

  • simplexml_load_string() Load xml string

  test 10 man '; $xml =simplexml_load_string($xml); //xml转object $xml= json_encode($xml); //objecct转json $xml=json_decode($xml,true); //json转array var_dump($xml);

How to parse xml to array in php

Recommended tutorial: "php tutorial"

The above is the detailed content of How to parse xml to array 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