DomDocument loading
Posted: Mon Feb 15, 2010 3:51 pm
Hi,
I'm fairly new to PHP. I am encountering some behavior which I'm sure translates into some basic hole in my PHP knowledge. Help is greatly appreciated.
Anyway, I'm loading a PHP 5 DomDocument in preparation for use in an xslt transformation. I want to load an xml string that has returned from a function call. In any case, when I do load() and provide the xml (pre-saved from a manual function call) as a file, it works fine. When I attempt to programatically invoke loadXML on the xml string however, the function always fails by returning FALSE.
To narrow it down I tried using small string literals. This fails if (!$xml_obj->loadXML('<root><node></root> '))
This succeeds (resulting in an empty DomDocument) if (!$xml_obj->loadXML(" "))
Is there some basic character escaping I need to do or anything? I'm puzzled but I'm sure there's one simple thing I don't know to do. Any help appreciated.
Thanks,
David
I'm fairly new to PHP. I am encountering some behavior which I'm sure translates into some basic hole in my PHP knowledge. Help is greatly appreciated.
Anyway, I'm loading a PHP 5 DomDocument in preparation for use in an xslt transformation. I want to load an xml string that has returned from a function call. In any case, when I do load() and provide the xml (pre-saved from a manual function call) as a file, it works fine. When I attempt to programatically invoke loadXML on the xml string however, the function always fails by returning FALSE.
To narrow it down I tried using small string literals. This fails if (!$xml_obj->loadXML('<root><node></root> '))
This succeeds (resulting in an empty DomDocument) if (!$xml_obj->loadXML(" "))
Is there some basic character escaping I need to do or anything? I'm puzzled but I'm sure there's one simple thing I don't know to do. Any help appreciated.
Thanks,
David