code: public function dump()
      {
          $dom = new DOMDocument('1.0');
          $dom->preserveWhiteSpace = false;
          $dom->formatOutput = true;
          $dom->loadXML($this->asXML());
          return $dom->saveXML();
      }
docs: Dump pretty XML