コード例 #1
0
<?php

ini_set('include_path', ini_get('include_path') . ':' . realpath(dirname(__FILE__) . '/..'));
require_once 'QuickBooks.php';
require_once 'QuickBooks/XML.php';
$xml = file_get_contents('/home/library_php/QuickBooks/data/InvoiceQuery.xml');
$Parser = new QuickBooks_XML($xml);
$errnum = 0;
$errmsg = '';
$Parser->parse($errnum, $errmsg);
//print_R($Parser);
$tmp = $Parser->children();
$base = current($tmp);
$tmp = $base->children();
$rs = next($tmp);
$tmp = $rs->children();
$qbxml = current($tmp);
Transform($qbxml);
function Transform($node)
{
    $name = $node->name();
    // table name
    $fields = array();
    $subtables = array();
    foreach ($node->children() as $child) {
        if (substr($child->name(), -3) == 'Ref') {
            // We need to look through the reference, and see if we can find it's unique identifier (is it a ListID? a FullName? a TxnID?)
            $fields[substr($child->name(), 0, -3) . '_ListID'] = array('link!');
        } else {
            if ($child->childCount()) {
                $child->setName($node->name() . '_' . $child->name());