Hi there PHP Builders I would like to say 'Hello World!' because that's my first post in this forum.
At the beginning of my XML adventure I faced such a problem:
structure.xml
<?xml version="1.0" encoding="utf-8"?>
<gallery>
<category id="1" txt="Blues">
<pic desc="Coma">1.jpg</pic>
<pic desc="Jakaśtam kapelka">2.jpg</pic>
<pic desc="Majka jerzowska">3.jpg</pic>
</category>
<category id="2" txt="Przyroda">
<pic desc="Jakieś drzewo">4.jpg</pic>
</category>
<category id="3" txt="Samochody">
<pic desc="Maluch">5.jpg</pic>
<pic desc="Mercedes">6.jpg</pic>
</category>
</gallery>
index.php
$doc = new DomDocument;
$doc->Load('structure.xml');
$list = $doc->getElementsByTagName('category');
echo count($list)."<br />";
var_dump($list);
- both files exist in root website folder
- php code returns:
1
object(DOMNodeList)#4 (0) { } 
Why php code doesn't put those three 'category' elements from .xml file to $list?
I would be thankful for tips. Greetings. P.