【问题标题】:Append QBXML declaration in XML with DOMDocument使用 DOMDocument 在 XML 中附加 QBXML 声明
【发布时间】:2013-12-01 03:32:09
【问题描述】:

尝试使用 PHP 中的 DOMDocument 为 QuickBooks 集成编写干净的 XML。我唯一坚持的是如何在<?xml version="1.0" encoding="utf-8"?> 之后添加所需的<?qbxml version="2.0"?> 以生成以下内容:

<?xml version="1.0" encoding="utf-8"?>
        <?qbxml version="2.0"?>
.....

这是我目前所拥有的......

$dom = new DOMDocument('1.0', 'utf-8');
   //Need to somehow add qbxml version here
    $qbxml = $dom->appendChild($dom->createElement('QBXML'));
    $qbxmlmsg = $qbxml->appendChild($dom->createElement('QBXMLMsgsRq'));
    $qbxmlmsg->setAttribute('onError', 'stopOnError');
    $salesReceiptAddRq = $qbxmlmsg->appendChild($dom->createElement('SalesReceiptAddRq'));
    $salesReceiptAddRq->setAttribute('requestID', 1234);
$dom->formatOutput = true;
    echo $dom->saveXML();

【问题讨论】:

    标签: php xml domdocument qbxml


    【解决方案1】:

    该节点称为处理指令。

    $dom = new DOMDocument('1.0', 'utf-8');
    $dom->appendChild($dom->createProcessingInstruction('qbxml', 'version="2.0"'));
    $qbxml = $dom->appendChild($dom->createElement('QBXML'));
    // ...
    
    echo $dom->saveXml();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-11
      • 2014-09-16
      相关资源
      最近更新 更多