0
<?xml version="1.0" encoding="utf-8"?>
<info>
   <report id="1">
      <book>
          <title>A</title>
          <price>10</price>
      </book>
      <author>
          <name>xyz</name>
          <mail>m.m@m</mail>
      </author>
   </report>
   <report id="2">
       <book>
           <title>B</title>
           <price>11</price>
       </book>
       <author>
           <name>xyz</name>
           <mail>m.m@m</mail>
       </author>
   </report>
   <report id="3">
       <book>
           <title>C</title>
           <price>13</price>
       </book>
       <author>
           <name>xyz</name>
           <mail>m.m@m</mail>           
       </author>
  </report>
</info>

"title="A",price="10" and name="xyz",mail="m.m@m"这是我的 xml,我想在这里使用它的标记名(如)检索每个报告及其标记值

$reportList = $document->getElementsByTagName('report');
foreach($reportList  as $reportNode)
{
    $books = $reportNode->getElementsByTagName('book');
    foreach($books as $book)
    {
        return $book->nodeValues;
    }


它返回“ A 10”但我想要"title="A",price="10"

4

0 回答 0