0x80040400:QuickBooks 在解析提供的 XML 文本流时发现错误

0x80040400: QuickBooks found an error when parsing the provided XML text stream

我正在为 QuickBooks 桌面使用 consobyte PHP SDK,当我尝试添加非库存项目时,它抛出错误 0x80040400:QuickBooks 在解析提供的 XML 文本流时发现错误.

<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <ItemNonInventoryAddRq requestID="38">
      <ItemNonInventoryAdd>
        <Name>46428</Name>
        <SalesAndPurchase>
          <SalesDesc>Apple Watch (not Sport)</SalesDesc>
          <SalesPrice>50.00</SalesPrice>
          <IncomeAccountRef>
            <FullName>Merchandise Sales</FullName>
          </IncomeAccountRef>
          <PurchaseDesc>Apple Watch (not Sport)</PurchaseDesc>
          <PurchaseDesc>50.00</PurchaseDesc>
          <ExpenseAccountRef>
            <FullName>Repairs and Maintenance</FullName>
          </ExpenseAccountRef>
        </SalesAndPurchase>
      </ItemNonInventoryAdd>
    </ItemNonInventoryAddRq>
  </QBXMLMsgsRq>
</QBXML>

解决这个问题:

   <PurchaseDesc>Apple Watch (not Sport)</PurchaseDesc>
   <PurchaseDesc>50.00</PurchaseDesc>

每当您收到此错误消息时:

0x80040400: QuickBooks found an error when parsing the provided XML text stream.

您应该做的第一件事是仔细查看您的 XML。然后 运行 通过 QuickBooks SDK 附带的 XML Validator 工具。它会准确地告诉你哪里出了问题:

Line: 15
LinePos: 25
Src Text: <PurchaseDesc>50.00</PurchaseDesc>
Reason: Element content is invalid according to the DTD/Schema.
Expecting: PurchaseCost, PurchaseTaxCodeRef, ExpenseAccountRef, PrefVendorRef.