How does php parse xml tags that have both values and attributes?
巴扎黑
巴扎黑 2017-06-14 10:50:11
0
1
673

use:

$xml = simplexml_load_string($content); $array = json_decode(json_encode((array) $xml), 1);

When parsing XML into an array in this way,
For:

  

and

content

can be parsed correctly, but for this:

content

You cannot get the name attribute, but you can only get the content content.

Is there any good way to deal with this problem?

巴扎黑
巴扎黑

reply all (1)
我想大声告诉你
$xml = simplexml_load_string($content); foreach($xml->attributes() AS $a => $b) { echo "$a = $b 
"; }
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!