保存在PHP数组中的XML值[重复]

Possible Duplicate:
PHP - How to parse this xml?
Parse xml with php - storing parts into array (close to deletion or already deleted)

If I had the following XML file and I wanted to save the values in the tags name and number into an array called department, how would I be able to do it using PHP?

  <?xml version="1.0"?>
  <data>
    <record id="1">
      <department>
        <name>ACME</name>
        <number>5</number>
      </department>
      <floor>
        <name>ACME Floor</name>
        <number>5</number>
      </floor>
    </record>
  </data>

You should use

DOMDocument::loadXML

<?php
    $doc = new DOMDocument();
    $doc->load('book.xml');
    $books = $dom->getElementsByTagName('book');
    foreach ($books as $book) {
        echo $book->nodeValue, PHP_EOL;
    }

?>