doujiao1949 2013-12-01 03:32
浏览 35
已采纳

使用DOMDocument在XML中附加QBXML声明

Trying to write clean XML for a QuickBooks integration using DOMDocument in PHP. The only thing I am stuck on is how to add the required <?qbxml version="2.0"?> after <?xml version="1.0" encoding="utf-8"?> to produce the following:

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

Here is what I have so far..

$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();
  • 写回答

1条回答 默认 最新

  • douxiongye5779 2013-12-01 10:31
    关注

    That node is called a processing instruction.

    $dom = new DOMDocument('1.0', 'utf-8');
    $dom->appendChild($dom->createProcessingInstruction('qbxml', 'version="2.0"'));
    $qbxml = $dom->appendChild($dom->createElement('QBXML'));
    // ...
    
    echo $dom->saveXml();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿