Location: PHPKode > scripts > XML Helper > tests/stand-alone-test.php
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    include '../XmlHelper.class.php';

    $xmlString = file_get_contents(dirname(__FILE__) . "/testXmlData/55521_total_only.xml");
    $helper = new XmlHelper();
    $helper->setCaseFolding(false);
    $helper->setTrimText(true);
    $data = $helper->xmlToArray ($xmlString);
//    print_r($data);
    assert(is_array($data));
    assert('USD' == $data['Order']['attributes']['currency']);
    assert('rogue-55521' == $data['Order']['attributes']['id']);
    assert('166.95' == $data['Order']['Total']['Line'][0]['value']);
    assert(8.32 == $data['Order']['Total']['Line'][1]['value']);
    assert(24 == $data['Order']['Total']['Line'][2]['InnerLine']['value']);
    assert(175.27 == $data['Order']['Total']['Line'][3]['value']);
    assert('Subtotal' == $data['Order']['Total']['Line'][0]['attributes']['type']);
    assert('Shipping' == $data['Order']['Total']['Line'][1]['attributes']['type']);
    assert('Tax' == $data['Order']['Total']['Line'][2]['attributes']['type']);
    assert('Total' == $data['Order']['Total']['Line'][3]['attributes']['type']);

    // Convert the array back to XML and assert that it is the same as the original XML.

    $xml = $helper->arrayToXml($data);
    $save = $helper->xmlToArray($xml);
    assert($data == $save);
?>
Return current item: XML Helper