简体   繁体   中英

How save xml in node with cdata in php?

how can I save an xml inside a node of another xml with cdata?

   $cddatacom = $xmlDoc->createCDATASection($arraydata['comprobante']); 
    $root = $xmlDoc->appendChild($xmlDoc->createElement("autorizacion"));
    $root->appendChild($xmlDoc->createElement("estado",$arraydata['estado']));
    $root->appendChild($xmlDoc->createElement("numeroAutorizacion",$arraydata['numeroAutorizacion']));
    $root->appendChild($xmlDoc->createElement("fechaAutorizacion",$arraydata['fechaAutorizacion']));
    $root->appendChild($xmlDoc->createElement("ambiente",$arraydata['ambiente']));
    $root->appendChild($xmlDoc->createElement("comprobante",$arraydata['comprobante']));
    $root->appendChild($xmlDoc->createElement("compro",$cddatacom));
    $xmlDoc->formatOutput = true;

Display this error

Object of class DOMCdataSection could not be converted to string

Thanks

I found the solution, next I put how I created the document

    $comprobante=$xml->createElement("comprobante");
    $autorizacion->appendChild($comprobante);

    $comprobanteCDATA = $xml->createCDATASection($Dcomprobante); 
    $comprobante->appendChild($comprobanteCDATA);

That's it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM