function toString($depth = 0) { $retString = $this->xxmlDoc->toString($depth); if ($depth == MINIXML_NOWHITESPACES) { $xmlhead = "<?xml version=\"1.0\"\\1?>"; } else { $xmlhead = "<?xml version=\"1.0\"\\1?>\n "; } $search = array("/<PSYCHOGENIC_ROOT_ELEMENT([^>]*)>\\s*/smi", "/<\\/PSYCHOGENIC_ROOT_ELEMENT>/smi"); $replace = array($xmlhead, ""); $retString = preg_replace($search, $replace, $retString); if (MINIXML_DEBUG > 0) { _MiniXMLLog("MiniXML::toString() Returning XML:\n{$retString}\n\n"); } return $retString; }
function toStringNoWhiteSpaces() { if (MINIXML_DEBUG > 0) { _MiniXMLLog("MiniXMLNode::toStringNoWhiteSpaces() call with depth {$depth}"); } if (!is_null($this->xtext)) { /* a text element */ $retStr = $this->xtext; } elseif (!is_null($this->xnumeric)) { /* a numeric element */ $retStr = $this->xnumeric; } return $retStr; }
function toStringNoWhiteSpaces() { $retString = ''; $attribString = ''; $elementName = $this->xname; foreach ($this->xattributes as $attrname => $attrvalue) { $attribString .= "{$attrname}=\"{$attrvalue}\" "; } $retString = "<{$elementName}"; if ($attribString) { $attribString = rtrim($attribString); $retString .= " {$attribString}"; } if (!$this->xnumChildren) { /* No kids -> no sub-elements, no text, nothing - consider a <unary/> element */ $retString .= " />"; return $retString; } /* If we've gotten this far, the element has ** kids or text - consider a <binary>otherstuff</binary> element */ $retString .= ">"; /* Loop over all kids, getting associated strings */ for ($i = 0; $i < $this->xnumChildren; $i++) { if (method_exists($this->xchildren[$i], 'toStringNoWhiteSpaces')) { $newStr = $this->xchildren[$i]->toStringNoWhiteSpaces(); if (!is_null($newStr)) { $retString .= $newStr; } } else { _MiniXMLLog("Invalid child found in {$elementName}"); } /* end if has a toString method */ } /* end loop over all children */ /* add the indented closing tag */ $retString .= "</{$elementName}>"; return $retString; }