private function buildElement($twiml, $document) {
    	$element = $document->createElement($twiml->name);

        foreach ($twiml->attributes as $name => $value) {
            if (is_bool($value)) {
                $value = ($value === true) ? 'true' : 'false';
            }
            $element->setAttribute($name, $value);
        }

        foreach ($twiml->children as $child) {
			if (is_string($child)) {
				$element->appendChild($document->createTextNode($child));
			} else {
				$element->appendChild($this->buildElement($child, $document));
			}
		}

        return $element;
    }
private function buildElement($twiml, $document) {
    	$element = $document->createElement($twiml->name);

        foreach ($twiml->attributes as $name => $value) {
            if (is_bool($value)) {
                $value = ($value === true) ? 'true' : 'false';
            }
            $element->setAttribute($name, $value);
        }

        foreach ($twiml->children as $child) {
			if (is_string($child)) {
				$element->appendChild($document->createTextNode($child));
			} else {
				$element->appendChild($this->buildElement($child, $document));
			}
		}

        return $element;
    }
private function buildElement ( $ twiml , $ document ) { $ element = $ document -> createElement ( $ twiml -> name ) ; foreach ( $ twiml -> attributes as $ name => $ value ) { if ( is_bool ( $ value ) ) { $ value = ( $ value === true ) ? 'true' : 'false' ; } $ element -> setAttribute ( $ name , $ value ) ; } foreach ( $ twiml -> children as $ child ) { if ( is_string ( $ child ) ) { $ element -> appendChild ( $ document -> createTextNode ( $ child ) ) ; } else { $ element -> appendChild ( $ this -> buildElement ( $ child , $ document ) ) ; } } return $ element ; }
Build TwiML element.

@param TwiML $twiml TwiML element to convert to XML
@param DOMDocument $document XML document for the element
@return DOMElement $element
Build TwiML element .