Fork me on GitHub

DOMDocument类文件

http://php.net/manual/en/class.domdocument.php

  1. <?php
  2. $xml = <<< XML
  3. <?xml version="1.0" encoding="utf-8" ?>
  4. <books>
  5. <book>Patterns of Enterprise Application Architecture</book>
  6. <book>Design Patterns:Elements of Reusable SoftWare Design</book>
  7. <book>Clean Code</book>
  8. </books>
  9. XML;
  10. $dom = new DOMDocument;
  11. $dom->loadXML($xml);
  12. $books = $dom->getElementsByTagName('book');
  13. foreach($books as $book){
  14. echo $book->nodeValue,PHP_EOL;
  15. }





posted @ 2016-01-13 10:22  LookPHP  阅读(397)  评论(0编辑  收藏  举报