Изучаю на практике SimpleXML, простой пример из документации с моим XML не работает. В чем может быть проблема?
Код | //не работает $xml = simplexml_load_file('Arrays.xml'); echo $xml->category->sub_category->snippet[0]->description;
//работает $rss = simplexml_load_file('http://partners.userland.com/nytRss/nytHomepage.xml'); echo $rss->channel->title;
|
кусок XML, весь приводить не буду - и так думаю будет ясно:
Код | <?xml version='1.0' encoding='UTF-8'?> <category name="Algorithms"> <sub_category name="Arrays"> <snippet name="(minus - subtract ) arrays" author="mindf" date_modified="01 Dec 2000" date_entered="01 Dec 2000" rating="3.25"> <description> In this simple function you send two arrays and it gives you an array with the operation A-B, elements on A that are not included on B. </description> <code> function RestaDeArrays($vectorA,$vectorB) { $cantA=count($vectorA); $cantB=count($vectorB); $No_saca=0; for($i=0;$i<$cantA;$i++) { for($j=0;$j<$cantB;$j++) { if($vectorA[$i]==$vectorB[$j]) $No_saca=1; }
if($No_saca==0) $nuevo_array[]=$vectorA[$i]; else $No_saca=0; }
return $nuevo_array; }
</code> </snippet> <snippet name="a more readable option that "print_r"" author="Saibot" date_modified="02 Dec 2000" date_entered="02 Dec 2000" rating="3.80"> <description> ....
|
|