/framework/core/xml/XmlNodeList.php

http://zoop.googlecode.com/ · PHP · 38 lines · 34 code · 4 blank · 0 comment · 1 complexity · b234438585a81ed6d86cb5f52b9f77b8 MD5 · raw file

  1. <?php
  2. class XmlNodeList implements Iterator
  3. {
  4. var $nodeList;
  5. function XmlNodeList($inNodeData)
  6. {
  7. $this->nodeList = $inNodeData->firstChild;
  8. }
  9. function rewind()
  10. {
  11. if($this->valid())
  12. $this->nodeList = $this->nodeList->parentNode->firstChild;
  13. }
  14. function current()
  15. {
  16. return is_null($this->nodeList) ? false : new XmlNode($this->nodeList);
  17. }
  18. function key()
  19. {
  20. trigger_error("I don't think that we actually use this");
  21. return key($this->nodeList);
  22. }
  23. function next()
  24. {
  25. $this->nodeList = $this->nodeList->nextSibling;
  26. return is_null($this->nodeList) ? false : new XmlNode($this->nodeList);
  27. }
  28. function valid()
  29. {
  30. return $this->current() !== false;
  31. }
  32. }