simpleXML: Anzahl der Knoten herausfinden
karlo w.
- php
0 Devius
Hallo Forum,
ich habe folgende XML-Datei
<data name="data">
<type id="0" name="Video">
<info id="0">
<![CDATA[<p>Video blablabla</p>]]>
</info>
<projects id="1">
<project id="0">
...
</project>
<project id="1">
...
</project>
<project id="2">
...
</project>
</projects>
</type>
<type id="1" name="Audio">
<info id="0">
<![CDATA[<p>Audio blablabla</p>]]>
</info>
<projects id="1">
<project id="0">
...
</project>
</projects>
</type>
</data>
Jetzt würde ich gerne die Anzahl der Projekte in der jeweiligen Rubrik (Video bzw Audio) ausgeben. Im Forum bin ich uf folenden thread gestoßen:
http://forum.de.selfhtml.org/archiv/2008/5/t171758/
Leider bekomm ich es aber nicht hin.
echo count($xml->xpath("/data/type/projects"));
Das liegert bei mir immer als Ergebnis "2", also die Anzahl der Rubriken, aber nicht der Projekte IN der Rubrik. Jemand einen Tipp?
Vielen Dank und Gruß
karlo
Hallo karlo,
versuche es doch mal mit echo count($xml->xpath("/data/type/projects/project"));. Eventuell hilft es ja...
Auf Wiederlesen
Devius