XML PHP #text problem

wxdqz

New Member
Hello again

Could anyone tell me why I get the following results?

The root element is British_Birds.
There are 1 child elements.
They are:
#text
resident
#text
rarevisitors
#text
-------------------
There should be 2 child elements and why is there #text in the results? I tried looking for answers but search engines won't accept a # in the query.

Thanks

Solaar
code:-
<?php

$XMLDoc = DOMDocument::load('birds5.xml');

$root = $XMLDoc->documentElement;
echo("The root element is " . $root->nodeName . ".<br />");

$children = $root->childNodes;

echo("There are " . count($children) . " child elements. <br />");
echo("They are: <br />");

for ($child = $root->firstChild;
$child;
$child = $child->nextSibling){

echo $child->nodeName;
echo "<br />";

}


?>

birds5.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v2006 (<!-- m --><a class="postlink" href="http://www.altova.com">http://www.altova.com</a><!-- m -->) -->

<British_Birds>

<resident>
<name>Golden oriole</name>
<latin>Oriolus oriolus</latin>
<status>Summer</status>
<breeding>9-42</breeding>
<passage>85</passage>
<image>siskin.jpg</image>
<url>www.rspb.org.uk/birds/guide/s/siskin/index.asp</url>

</resident>

<rarevisitors>
<name>Hawk Owl</name>
<latin>Accipiter nisus</latin>
<status>rarevisitor</status>
<breeding>0</breeding>
<passage>0</passage>
<image>hawkowl.jpg</image>
<url>www.rspb.org.uk/birds/guide/h/hawkowl/index.asp</url>
</rarevisitors>

</British_Birds>
 
Back
Top