Try to avoid "PHP Warning: DOMDocument::loadXML(): Empty string supplied as input"

This commit is contained in:
nathan 2021-11-03 09:30:58 -06:00
parent 77935c1feb
commit ddaef879a8

View File

@ -74,15 +74,26 @@ class importexport_arrayxml {
* @param string $_xml
* @return array
*/
public static function xml2array( $_xml ) {
if ( $_xml instanceof DOMElement ) {
public static function xml2array( $_xml )
{
if($_xml instanceof DOMElement)
{
$n = &$_xml;
} else {
}
elseif($_xml)
{
$n = new DOMDocument;
$loaded = $n->loadXML($_xml);
if(!$loaded) return array();
if(!$loaded)
{
return array();
}
}
$xml_array = array();
if(!$_xml || !$n)
{
return $xml_array;
}
foreach($n->childNodes as $nc) {