Ejemplo n.º 1
0
 /**
  * recursive function for xml output
  * @return string
  */
 function writeTag($xmlNode, $depth)
 {
     $tabs = '';
     if ($depth) {
         $tabs = str_repeat("\t", $depth);
     }
     $out = $tabs;
     $childs = count($xmlNode['children']);
     // open tag
     $out .= fuXml::openTag($xmlNode['name'], $xmlNode['attributes'], 'oneliner' == $xmlNode['type'], $childs);
     // content
     if ('oneliner' != $xmlNode['type'] && $xmlNode['content']) {
         $out .= $xmlNode['content'];
         if ($childs) {
             $out .= "\n";
         }
     }
     // childs
     if ($childs) {
         for ($i = 0; isset($xmlNode['children'][$i]); $i++) {
             $out .= fuXml::writeTag($xmlNode['children'][$i], $depth + 1);
         }
     }
     // close
     if ('oneliner' != $xmlNode['type']) {
         if ($childs) {
             $out .= "{$tabs}";
         }
         $out .= '</' . $xmlNode['name'] . ">\n";
     }
     return $out;
 }
Ejemplo n.º 2
0
<?php

$test_file = implode("", file('xml_note.xml'));
include_once "../lib/fuxml.class.php";
include_once "../lib/fuxmlsax.class.php";
include_once "../lib/fubench.class.php";
$b = new fuBench();
$b->round = 10;
$b->addPoint("fuXmlSAX");
$xmlpar =& new fuXmlSax();
$tree = $xmlpar->parse($test_file);
$b->endPoint();
nl2br(htmlspecialchars(print_r($tree)));
echo "fuXML<BR><BR>\n\n";
$b->addPoint("fuXml");
$tree2 = fuXml::arrayTree($test_file);
$b->endPoint();
nl2br(htmlspecialchars(print_r($tree2)));
$b->endBench();