コード例 #1
0
// Error reporting
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
// Our test XML tag
$xml = '
	<Tag1>
		<NestedTag age="25" gender="male" note="Keith &quot;Worminator&quot; Palmer">
			<AnotherTag>Keith</AnotherTag>
		</NestedTag>
	</Tag1>';
// Create the new object
$Parser = new QuickBooks_XML_Parser($xml);
// Parse the XML document
$errnum = 0;
$errmsg = '';
if ($Parser->validate($errnum, $errmsg)) {
    // Parse it into a document
    $Doc = $Parser->parse($errnum, $errmsg);
    // Get the root node from the document
    $Root = $Doc->getRoot();
    // Now fetch some stuff from the parsed document
    print 'Hello there ' . $Root->getChildDataAt('Tag1 NestedTag AnotherTag') . "\n";
    print_r($Root->getChildAttributesAt('Tag1 NestedTag'));
    print "\n";
    print 'Root tag name is: ' . $Root->name() . "\n";
    $NestedTag = $Root->getChildAt('Tag1 NestedTag');
    print_r($NestedTag);
}
$xml2 = '
	<Animals>
		<Animal id="1">
コード例 #2
0
 protected static function _doAddResponse($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
 {
     //print('THIS GOT CALLED!');
     //print_r($extra);
     // This is stuff we'll be passing to the callback handler functions/methods
     $method = null;
     // $action
     // $ID
     $err = '';
     $qbxml =& $xml;
     $qbobject = null;
     $qbres = null;
     if (isset($extra['method'])) {
         $method = $extra['method'];
     }
     $xml_errnum = 0;
     $xml_errmsg = '';
     //print($xml);
     $Object = null;
     if ($action) {
         $Parser = new QuickBooks_XML_Parser($xml);
         if ($Parser->validate($xml_errnum, $xml_errmsg) and $Doc = $Parser->parse($xml_errnum, $xml_errmsg)) {
             $Root = $Doc->getRoot();
             // There is some nested garbage we don't really need here... let's get rid of it
             $Response = $Root->getChildAt('QBXML QBXMLMsgsRs ' . $action . 'Rs');
             $Child = null;
             if ($Response) {
                 $Child = $Response->getChild(0);
                 // Try to build an object from the returned XML
                 //if ($qbobject = QuickBooks_Callbacks_API_Callbacks::_objectFromAction($action, $paths))
                 if ($Object = QuickBooks_Callbacks_API_Callbacks::_objectFromXML($action, $Child)) {
                 } else {
                     $Object = null;
                 }
             }
         } else {
             $err = 'XML parser error: ' . $xml_errnum . ': ' . $xml_errmsg;
         }
     }
     if ($err) {
         return false;
     }
     if (isset($extra['callbacks']) and is_array($extra['callbacks'])) {
         QuickBooks_Callbacks_API_Callbacks::_callCallbacks($extra['callbacks'], $method, $action, $ID, $err, $qbxml, $Object, $qbres);
     }
     return true;
 }