forked from extern/egroupware
Try to avoid "PHP Warning: DOMDocument::loadXML(): Empty string supplied as input"
This commit is contained in:
parent
a5602845c9
commit
6cd8f67985
@ -74,15 +74,26 @@ class importexport_arrayxml {
|
|||||||
* @param string $_xml
|
* @param string $_xml
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function xml2array( $_xml ) {
|
public static function xml2array( $_xml )
|
||||||
if ( $_xml instanceof DOMElement ) {
|
{
|
||||||
|
if($_xml instanceof DOMElement)
|
||||||
|
{
|
||||||
$n = &$_xml;
|
$n = &$_xml;
|
||||||
} else {
|
}
|
||||||
|
elseif($_xml)
|
||||||
|
{
|
||||||
$n = new DOMDocument;
|
$n = new DOMDocument;
|
||||||
$loaded = $n->loadXML($_xml);
|
$loaded = $n->loadXML($_xml);
|
||||||
if(!$loaded) return array();
|
if(!$loaded)
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$xml_array = array();
|
$xml_array = array();
|
||||||
|
if(!$_xml || !$n)
|
||||||
|
{
|
||||||
|
return $xml_array;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($n->childNodes as $nc) {
|
foreach($n->childNodes as $nc) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user