Пример #1
0
<?php

require_once "XML_PullParser.inc";
$child_tags = array();
$tags = array("ipaddress", "domain");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    if ($parser->XML_PullParser_isTypeOf('ipaddress', $token)) {
        echo "IP address: " . $parser->XML_PullParser_getText('ipaddress') . "\n";
    } else {
        echo "Domain Name: " . $parser->XML_PullParser_getText('domain') . "\n";
    }
}
Пример #2
0
function parse_files($file)
{
    global $pattern, $constants_pattern;
    XML_PullParser_excludeBlanks(true);
    XML_PullParser_trimCdata(true);
    $tags = array("formalpara", "blockquote", "simpara");
    $child_tags = array('programlisting', "title", "para", "simplelist", "member");
    $parser = new XML_PullParser($file, $tags, $child_tags);
    XML_PullParser_excludeBlanks(true);
    XML_PullParser_trimCdata(true);
    $token = "";
    while ($token = $parser->XML_PullParser_getToken()) {
        if ($parser->XML_PullParser_isTypeOf("formalpara", $token)) {
            $title = $parser->XML_PullParser_getElement('title');
            $title = $parser->XML_PullParser_getText($title);
            if ($title) {
                if (preg_match_all('/XML_PullParser(_\\w+)/', $title, $matches)) {
                    index_functions($matches[1]);
                }
            }
            $para = $parser->XML_PullParser_getElement('para');
            if ($text = $parser->XML_PullParser_getText($para)) {
                if (preg_match_all($constants_pattern, $text, $matches)) {
                    index_constants($matches[1]);
                } elseif (preg_match_all('/XML_PullParser(_\\w+)/', $text, $matches)) {
                    index_functions($matches[1]);
                } elseif (preg_match_all($pattern, $text, $matches)) {
                    index_terms($matches[1]);
                }
            }
        } elseif ($parser->XML_PullParser_isTypeOf("blockquote", $token)) {
            $title = $parser->XML_PullParser_getText('title');
            if ($title) {
                if (preg_match_all('/XML_PullParser(_\\w+)/', $title, $matches)) {
                    index_functions($matches[1]);
                }
            }
        } elseif ($parser->XML_PullParser_isTypeOf("simpara", $token)) {
            $text = $parser->XML_PullParser_getText($token);
            if (preg_match_all($constants_pattern, $text, $matches)) {
                index_constants($matches[1]);
            } elseif (preg_match_all('/XML_PullParser(_\\w+)/', $text, $matches)) {
                index_functions($matches[1]);
            }
        }
    }
    $parser->XML_PullParser_free();
}
Пример #3
0
function getHeader($file)
{
    $tags = array("title", "articleinfo");
    $child_tags = array("");
    $parser = new XML_PullParser($file, $tags, $child_tags);
    echo "<div class='header'>";
    while ($token = $parser->XML_PullParser_getToken()) {
        if ($parser->XML_PullParser_isTypeOf("title", $token)) {
            $title = $parser->XML_PullParser_getText();
            $subtitle = $parser->XML_PullParser_getAttributes("title");
            echo "<span class='title'>{$title}</span><br>\n";
            if ($subtitle) {
                echo '<span class="subtitle">' . $subtitle['ROLE'] . "</span><br>\n";
            }
        } elseif ($parser->XML_PullParser_isTypeOf("articleinfo", $token)) {
            $surname = $parser->XML_PullParser_getText("surname");
            $firstname = $parser->XML_PullParser_getText("firstname");
            $version = $parser->XML_PullParser_getText("releaseinfo");
            $email = $parser->XML_PullParser_getText("email", 1);
            $subtitle_2 = $parser->XML_PullParser_getText("subtitle");
            if ($version) {
                echo "<b>{$version}</b><br>\n";
            }
            echo "<b>{$firstname} {$surname}</b><br>\n";
            if ($email) {
                echo "<b>{$email}</b><br><br>\n";
            }
            echo "<span class='subtitle_2'>{$subtitle_2}</span><br>\n";
            break;
        }
    }
    $parser->XML_PullParser_free();
    echo "</div>";
    echo "<p><div class='block'>";
    echo '<table width=800 cellpadding = 8><tr><td align = "right"><A href="contents.html" class="navigation_2">Contents</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></table>';
    echo "</div>";
}