On Fri, 17 May 2002, peter tatischev wrote:
> What is the type of array returned by child_nodes()?
> I have an XML doc parsed into a DOM structure by
> $docnode = domxml_open_file("blah")
>
> then I get root by
> $root = $docnode->document_element();
> then I get the first node
> $f_child = $root->first_child();
> and then I want to get an array of all the children of f_child,
> like this
> $children = $f_child->child_nodes();
> presumably it should give me an array of dom_nodes, and I should
> be able to perform actions with those, e.g.
> $children[0]->node_type();
> or something similar, however, I get
> <b>Fatal error</b>: Call to a member function on a non-object in
It's not clear for which call you get the Fatal Error. Check each call to a DOMXML
method like:
if(!object->method()){
print("ERROR in calling method()");
}
The DOMXML methods return either a valid object or FALSE in case of error. Also I'd
suggest setting error_reporting(E_ALL); at the begining of your script when doing
development.
An intermmediate check would be if $f_child->child_nodes() returns an array
(is_array()).
FINALLY: check for spelling mistakes in your variable names; It sounds stupid but I
spent 1 hour once because I was just getting the "call to a member function on a
non-object...".
cheers,
thalis
>
> Am I missing something here?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php