# SimpleXML -\> Count

**URL:** <https://forum.kirupa.com/t/simplexml-count/276548>\
**Category:** programming\
**Created:** [November 30, 2008, 7:23pm UTC](https://forum.kirupa.com/t/simplexml-count/276548 "2008-11-30T19:23:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenBart](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@BenBart](https://forum.kirupa.com/u/BenBart)\
**Post date:** [November 30, 2008, 7:23pm UTC](https://forum.kirupa.com/t/simplexml-count/276548/1 "2008-11-30T19:23:36Z")

</div>

```auto
$xmlFileData = file_get_contents('random.xml');
$xmlData = new SimpleXMLElement($xmlFileData);

$totalPages = count($xmlData->page)-1;

```

The last line of code will tell me how many fields of “page” I have. But it only works on my test server. When I upload it to my real server it doesn’t work any more. How can I count the about of fields with a SimpleXMLElement?
