3

I've come across the following xml when dealing with Quickbooks xml integration:

<?xml version="1.0" ?>
<?qbxml version="5.0" ?>
<QBXML>
  <QBXMLMsgsRq onError="stopOnError">
    <CustomerQueryRq requestID="5001" iterator="Start"> 
      <MaxReturned>10</MaxReturned> 
      <IncludeRetElement>ListID</IncludeRetElement>
    </CustomerQueryRq>
  </QBXMLMsgsRq>
</QBXML>

I'm familiar with the <?xml ...?> declaration, but I'm confused with the <?qbxml version="5.0" ?> part. I'm assuming this the xml version that Quickbooks understands. Is this xml valid? Can it be managed with regular java parsers and transformer?

I've tried loading the xml with the regular DocumentBuilderFactory and generating output with TransformerFactory but the <?qbxml ...?> gets lost in the process. Any ideas on how do I need to configure the builders and transformers in order to maintain the <?qbxml ...?> declaration?

Ricardo Marimon
  • 10,339
  • 9
  • 52
  • 59

1 Answers1

4

<?qbxml version="5.0" ?> is a Processing Instruction. It means something to Quickbooks, but you can ignore it unless it contains information you can use somehow. If you're using XSLT to do your processing, you can use <xsl:processing-instruction> to create PIs and processing-instruction() to match them in your templates. Once you've parsed the document into a DOM, I don't think there's an easy way to get PIs via the DOM API, though you can certainly create new ones. There is a ContentHandler method for PIs, so you can do things with them during parsing if you want.

hcayless
  • 1,036
  • 6
  • 7