Parsing a xml file using simplexml and accessing properties

前端 未结 1 564
無奈伤痛
無奈伤痛 2021-01-16 02:19

I am trying to parse a xml file which has this structure:

 
- 

        
1条回答
  •  粉色の甜心
    2021-01-16 02:26

    Try this out:

    $resXml = simplexml_load_file($requestUrl); //$requestUrl is where the xml file is located
    
    foreach ($resXml->readCalls->classify->classification->class as $d) {
        $currClassificationName = $d['className'];
        $currClassificationRating = (float) $d['p'];
        echo "$currClassificationName: $currClassificationRating" . "
    "; }

    0 讨论(0)
提交回复
热议问题