Exemplo n.º 1
0
$start = microtime(true);
// Our test XML tag
$xml = '
	<Tag1>
		<NestedTag age="25" gender="male" 
			note="Keith &quot;Worminator&quot; Palmer">
			<AnotherTag>Keith</AnotherTag>
		</NestedTag>
	</Tag1>';
$use_parser = null;
// Auto-detect the best choice
//$use_parser = QuickBooks_XML::PARSER_BUILTIN;		// Use the built in XML parser
//$use_parser = QuickBooks_XML::PARSER_SIMPLEXML;		// Use the PHP simpleXML extension
// Create the new object
$Parser = new QuickBooks_XML_Parser($xml, $use_parser);
print 'Using backend: [' . $Parser->backend() . ']' . "\n";
print "\n";
// 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');
							<weight_mod><![CDATA[0.000]]></weight_mod>
						</transaction_detail_option>
					</transaction_detail_options>
				</transaction_detail>
			</transaction_details>
			<shipto_addresses/>
		</transaction>
	</transactions>
</foxydata>';
$use_parser = null;
// Auto-detect the best choice
//$use_parser = QuickBooks_XML::PARSER_BUILTIN;		// Use the built in XML parser
//$use_parser = QuickBooks_XML::PARSER_SIMPLEXML;		// Use the PHP simpleXML extension
// Create the new object
$Parser = new QuickBooks_XML_Parser($xml, $use_parser);
print 'Using backend: [' . $Parser->backend() . ']' . "\n";
print "\n";
// 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();
    $fp = fopen('dev_xml_performance.' . $Parser->backend() . '.txt', 'w+');
    fwrite($fp, print_r($Root, true));
    fclose($fp);
} else {
    print 'XML validation failed: [' . $errnum . ': ' . $errmsg . ']';
}