Marcello Impastato Marcello Impastato - 1 year ago 95
PHP Question

How to get number of nodes inside a xml file?

Having a xml file so formed:

<book id="1">
<chapter id="1">
<chapter id="2">
<chapter id="3">

How i can count nodes inside ... ?
In example above, the function should be turn 3 as result becouse present three nodes.

I access to ... so:

$xpath = new DOMXPath($filename);
$book = $xpath->query("//book[@id='1']")->item(0);

Answer Source

You can do as:



Unless you can use this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download