【问题标题】:How save xml in node with cdata in php?如何在 php 中使用 cdata 将 xml 保存在节点中?
【发布时间】:2019-11-23 17:36:29
【问题描述】:

如何使用 cdata 将 xml 保存在另一个 xml 的节点内?

   $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;

显示此错误

Object of class DOMCdataSection could not be converted to string

谢谢

【问题讨论】:

  • edit您的问题包含您正在使用的编程语言的标签。
  • 我正在编程的代码是php

标签: php xml cdata


【解决方案1】:

我找到了解决方案,接下来我介绍我是如何创建文档的

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

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

就是这样。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-09
    • 2021-02-28
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 2012-12-20
    • 2011-02-27
    • 1970-01-01
    相关资源
    最近更新 更多