Advertisement
fruffl

Untitled

Nov 5th, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. /*
  3. <data>
  4. <menu id="0" tpl="" name="Impressum" link="" target="" secure="">
  5.         <site id="0" tpl="index" name="Datenschutz" link="" target="" secure=""/>
  6.         <site id="1" tpl="index" name="Datenschutz" link="" target="" secure=""/>
  7.         <site id="2" tpl="index" name="Datenschutz" link="" target="" secure=""/>
  8. </menu>
  9. </data>
  10. */
  11. $doc = new DomDocument;
  12.  
  13. // We need to validate our document before refering to the id
  14. $doc->validateOnParse = true;
  15. $doc->load('php.xml');
  16. //header('Content-Type: text/xml');
  17. //echo $doc->saveXML();
  18.  
  19. $sites = $doc->getElementsByTagName('site'); // Find Sections
  20. foreach ($sites as $site) //go to each section 1 by 1
  21. {
  22.     if(($name = $doc->documentElement->nodeName) != 'site')
  23.         continue;
  24.  
  25.     var_dump($name.': '.$site->getAttribute('id'));
  26.        
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement