SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | ||
3 | /* | |
4 | - | <menu id="0" tpl="" name="Impressum" link="" target="" secure=""> |
4 | + | |
5 | - | <site id="0" tpl="index" name="Datenschutz" link="" target="" secure=""/> |
5 | + | <menu xml:id="bar0" tpl="" name="Impressum" link="" target="" secure=""> |
6 | - | <site id="1" tpl="index" name="Datenschutz" link="" target="" secure=""/> |
6 | + | <site xml:id="foo0" tpl="index" name="Datenschutz" link="" target="" secure=""/> |
7 | - | <site id="2" tpl="index" name="Datenschutz" link="" target="" secure=""/> |
7 | + | <site xml:id="foo1" tpl="index" name="Datenschutz" link="" target="" secure=""/> |
8 | <site xml:id="foo2" tpl="index" name="Datenschutz" link="" target="" secure=""/> | |
9 | <menu xml:id="bar1" tpl="" name="Impressum" link="" target="" secure=""> | |
10 | <site xml:id="foo10" tpl="index" name="Datenschutz" link="" target="" secure=""/> | |
11 | <site xml:id="foo11" tpl="index" name="Datenschutz" link="" target="" secure=""/> | |
12 | <site xml:id="foo12" tpl="index" name="Datenschutz" link="" target="" secure=""/> | |
13 | - | // We need to validate our document before refering to the id |
13 | + | </menu> |
14 | </menu> | |
15 | </data> | |
16 | */ | |
17 | $doc = new DomDocument; | |
18 | $doc->validateOnParse = true; | |
19 | - | $sites = $doc->getElementsByTagName('site'); // Find Sections |
19 | + | |
20 | - | foreach ($sites as $site) //go to each section 1 by 1 |
20 | + | |
21 | //header('Content-Type: text/xml'); | |
22 | - | if(($name = $doc->documentElement->nodeName) != 'site') |
22 | + | |
23 | ||
24 | var_dump($doc->getElementById('bar1')->tagName); // menu | |
25 | - | var_dump($name.': '.$site->getAttribute('id')); |
25 | + | |
26 | - | |
26 | + | $sites = $doc->getElementsByTagName('site'); |
27 | - | } |
27 | + | |
28 | foreach ($sites as $site) | |
29 | { | |
30 | ||
31 | if($site->getAttribute('xml:id') != 'foo11') | |
32 | continue; | |
33 | ||
34 | echo $site->parentNode->getAttribute('xml:id'); //bar1 | |
35 | } | |
36 | ||
37 |