예제 #1
0
 /**
  * Recursively walk through the element tree and write elements to the
  * XMLWriter instance.
  * 
  * @param XMLWriter $writer
  * @param Polycast_XmlRpc_Generator_Element $element
  * @return void
  */
 protected function _generateXml(XMLWriter $writer, Polycast_XmlRpc_Generator_Element $element)
 {
     $writer->startElement($element->getName());
     foreach ($element->getChildren() as $child) {
         if ($child instanceof Polycast_XmlRpc_Generator_Element) {
             /* @var $child Polycast_XmlRpc_Generator_Element */
             $this->_generateXml($writer, $child);
         } elseif ($child instanceof Polycast_XmlRpc_Value) {
             /* @var $child Polycast_XmlRpc_Value */
             $writer->writeRaw($child->saveXml());
         } else {
             $writer->text($child);
         }
     }
     $writer->endElement();
 }
예제 #2
0
 /**
  * Builds the document recursively.
  * 
  * @param DOMDocument $dom
  * @param Polycast_XmlRpc_Generator_Element $element
  * @param DOMElement $rootNode
  * @return void
  */
 protected function _generateXml(DOMDocument $dom, Polycast_XmlRpc_Generator_Element $element, DOMElement $rootNode = null)
 {
     $node = $dom->createElement($element->getName());
     if (is_null($rootNode)) {
         $dom->appendChild($node);
     } else {
         $rootNode->appendChild($node);
     }
     foreach ($element->getChildren() as $child) {
         if ($child instanceof Polycast_XmlRpc_Generator_Element) {
             /* @var $child Polycast_XmlRpc_Generator_Element */
             $this->_generateXml($dom, $child, $node);
         } elseif ($child instanceof Polycast_XmlRpc_Value) {
             /* @var $child Polycast_XmlRpc_Value */
             $importNode = new DOMDocument();
             $importNode->loadXML($child->saveXML());
             $node->appendChild($dom->importNode($importNode->documentElement, true));
         } else {
             $node->appendChild($dom->createTextNode($child));
         }
     }
 }