fork download
  1. <?php
  2. $str = <<<EOL
  3. <Cnt id="681">
  4.   <CFiles>
  5.   <CFile name="24801" id="24801"></CFile>
  6.   </CFiles>
  7.   <Pfiles>
  8.   <PFile name="1851" id="1851"></PFile>
  9.   </Pfiles>
  10. </Cnt>
  11. EOL;
  12.  
  13. $xml = simplexml_load_string($str);
  14.  
  15. echo 'CFile->name: ', $xml->CFiles->CFile->attributes()->name , PHP_EOL;
  16. echo 'CFile->id: ', $xml->CFiles->CFile->attributes()->id , PHP_EOL;
  17. echo 'PFile->name: ',$xml->Pfiles->PFile->attributes()->name , PHP_EOL;
  18. echo 'PFile->id: ',$xml->Pfiles->PFile->attributes()->id;
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
CFile->name: 24801
CFile->id: 24801
PFile->name: 1851
PFile->id: 1851