You are here

function patterns_xmlparser_dump in Patterns 7.2

Same name and namespace in other branches
  1. 7 patterns_xmlparser/patterns_xmlparser.module \patterns_xmlparser_dump()

File

patterns_xmlparser/patterns_xmlparser.module, line 67

Code

function patterns_xmlparser_dump($pattern = NULL, $append = NULL) {
  if (empty($pattern)) {
    return FALSE;
  }
  $xml = new SimpleXMLElement("<pattern/>");

  // function call to convert array to xml
  patterns_xmlparser_array_to_xml($pattern, $xml);

  // Use the DOMDcoument to format it nicely and indent it
  $doc = dom_import_simplexml($xml)->ownerDocument;
  $doc->preserveWhiteSpace = false;
  $doc->formatOutput = true;
  $dump = $doc
    ->saveXML();
  return is_null($append) ? $dump : $append . "\n" . $dump;
}