/**
  * convert dom to simpleXML
  * @param DOMElement $dom
  * @param $class cast to child class of SimpleXMLElement
  * @return SimpleXMLElement
  */
 public static function whole_dom_to_simplexml($dom, $class = 'SimpleXMLElement')
 {
     if ($dom instanceof DOMElement) {
         $save_xml = $dom->ownerDocument->saveXML();
     } elseif ($dom instanceof DOMDocument) {
         $save_xml = $dom->saveXML();
     }
     return simplexml_load_string($save_xml, $class, LIBXML_NOCDATA | LIBXML_NOERROR);
 }