コード例 #1
0
ファイル: toc.php プロジェクト: omusico/isle-web-framework
function toc($file)
{
    global $handle, $html_handle;
    global $files;
    $tags = array("para");
    $child_tags = array("ulink");
    $parser = new XML_PullParser($file, $tags, $child_tags);
    $next_url = "";
    $prev_url = "";
    while ($token = $parser->XML_PullParser_getToken()) {
        if ($link = $parser->XML_PullParser_getElement('ulink')) {
            while ($link = $parser->XML_PullParser_nextElement()) {
                $url_array = $parser->XML_PullParser_getAttributes($link);
                $url = $parser->XML_PullParser_getAttrVal('url', $url_array);
                $link_text = trim($parser->XML_PullParser_getText($link));
                $type = $parser->XML_PullParser_getAttrVal('type', $url_array);
                if ($type == "next") {
                    echo "<A href=\"article2html.php?fn={$url}\">{$link_text}</A><br>\n";
                    writeEntry($handle, "{$url}", $link_text);
                    writeHTMLEntry($html_handle, "{$url}", $link_text);
                    $next_url = $url;
                    $files[$next_url] = true;
                }
                if ($type == "prev") {
                    //  echo "Prev:  $link_text\n";
                }
            }
        }
    }
    $parser->XML_PullParser_free();
    return $next_url;
}
コード例 #2
0
<?php

require_once "XML_PullParser.inc";
$tags = array("entry");
$child_tags = array("server", "ipaddress", "domain");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    $parser->XML_PullParser_getElement('server');
    $seq = $parser->XML_PullParser_getSequence();
    for ($i = 0; $i < count($seq); $i++) {
        list($server, $which) = each($seq[$i]);
        $name = $parser->XML_PullParser_getText($server, $which);
        echo "Name: {$name}\n";
        $ip = $parser->XML_PullParser_getAttributes($server, $which);
        echo "\tIP: " . $parser->XML_PullParser_getAttrVal('ip', $ip) . "\n";
    }
}
/*
 Result
        Name:  example_1.com
                IP: 192.168.10.1
        Name:  example_2.com
                IP: 192.168.10.2
        Name:  example_3.com
                IP: 192.168.10.3
*/
コード例 #3
0
<?php

require_once "XML_PullParser.inc";
$tags = array("Entry");
$child_tags = array();
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    $seq = $parser->XML_PullParser_getSequence();
    for ($i = 0; $i < count($seq); $i++) {
        list($element, $which) = each($seq[$i]);
        switch ($element) {
            case 'IPADDRESS':
                echo "{$element}: {$which}\n";
                echo $parser->XML_PullParser_getText($element, $which) . "\n";
                break;
            case 'SERVER':
                echo "{$element}: {$which}\n";
                echo $parser->XML_PullParser_getText($element, $which) . "\n";
                $ip = $parser->XML_PullParser_getAttributes($element, $which);
                echo "\tIP: " . $parser->XML_PullParser_getAttrVal('ip', $ip) . "\n";
                break;
            case 'DOMAIN':
                echo "{$element}: {$which}\n";
                echo $parser->XML_PullParser_getText($element, $which) . "\n";
                break;
            case 'ALIAS':
                echo "{$element}: {$which}\n";
                echo $parser->XML_PullParser_getText($element, $which) . "\n";
                break;
            default:
                echo "default: {$element}: {$which}\n";
コード例 #4
0
<?php

require_once "XML_PullParser.inc";
$tags = array("Entry");
$child_tags = array("ipaddress");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    $ipaddress = $parser->XML_PullParser_getElement('ipaddress');
    echo "IP Adress: " . $parser->XML_PullParser_getText() . "\n";
}
/*  Result
        IP Adress: 172.20.19.6
    */
コード例 #5
0
<?php

require_once "XML_PullParser.inc";
XML_PullParser_excludeBlanks(true);
XML_PullParser_trimCdata(true);
$tags = array("DNS");
$child_tags = array("Entry");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    $entry = $parser->XML_PullParser_getElement("entry");
    $child = $parser->XML_PullParser_getChild("server", 2, $entry);
    $child = $parser->XML_PullParser_getText("server", 2, $entry);
    echo "{$child}\n";
    $attr_array = $parser->XML_PullParser_getAttributes("server", 2, $child);
    if ($attr_array) {
        foreach ($attr_array as $n => $v) {
            echo "{$n} -- {$v}\n";
        }
    } elseif ($attr_array === FALSE) {
        $err = XML_PullParser_Errors_userDefined("Bad Attributes array");
        echo XML_PullParser_Errors_getUserDefined($err) . "\n";
        echo XML_PullParser_Errors_Trace() . "\n";
        exit;
    }
}
/* Result
example_2.com
User defined error: Bad Attributes array
Line: 26, Top Level

------Error Trace------------
コード例 #6
0
<?php

require_once "XML_PullParser.inc";
$child_tags = array();
$tags = array("ipaddress");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    echo "IP address: " . $parser->XML_PullParser_getText('ipaddress') . "\n";
}
/*
 Result
 IP address: 172.20.19.6
*/
コード例 #7
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();
}
コード例 #8
0
<?php

//  Listing 18
require_once "XML_PullParser.inc";
//  XML_PullParser_excludeBlanks(true);
$tags = array("entry");
$child_tags = array("server", "domain");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
$token = $parser->XML_PullParser_getToken();
echo $parser->XML_PullParser_getText() . "\n";
$el = $parser->XML_PullParser_getElement("server");
echo $parser->XML_PullParser_getText() . "\n";
$parser->XML_PullParser_getElement("domain");
echo $parser->XML_PullParser_getText() . "\n";
/*
Result
 
 172.20.19.6
  example.com
  example_1.com
  example_2.com
  example_3.com
  www.example.com

 example_1.com example_2.com example_3.coM
 example.com
*/
?>

コード例 #9
0
<?php

require_once "XML_PullParser.inc";
$tags = array('para');
$child_tags = array();
$parser = new XML_PullParser("List.xml", $tags, $child_tags);
$parser->XML_PullParser_getToken();
$list = $parser->XML_PullParser_getChild('simpleList');
$which = 1;
$items = "";
echo " < OL>\n";
while ($member = $parser->XML_PullParser_getChild('member', $which, $list)) {
    $member_text = $parser->XML_PullParser_getText($member);
    $items .= " < LI>" . trim($member_text) . "\n";
    $which++;
}
echo $items;
echo " < /OL>\n";
/*  Result: Child token $member returned by XML_PullParser_getChild
    [8] => S__MEMBER
    [9] => Array
        (
        )

    [10] => Array
        (
            [cdata] =>
        array XML_PullParser_getChild (string $child, [integer $which = 1], [array $el = ""])

        )
コード例 #10
0
<?php

require_once "XML_PullParser.inc";
$tags = array("Entry");
$child_tags = array("server");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    $dns_servers = $parser->XML_PullParser_getElement('server');
    while ($server = $parser->XML_PullParser_nextElement()) {
        echo "Server: " . $parser->XML_PullParser_getText($server) . "\n";
    }
}
/*  Result
        Server: example_1.com
        Server: example_2.com
        Server: example_3.com
    */
コード例 #11
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";
    }
}
コード例 #12
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>";
}
コード例 #13
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 ($ip = $parser->XML_PullParser_getText('ipaddress')) {
        echo "IP address: " . $ip . "\n";
    }
    if ($domain = $parser->XML_PullParser_getText('domain')) {
        echo "Domain Name: " . $domain . "\n\n";
    }
}
/*
 Result
       IP address: 172.20.19.6
       Domain Name:  example.com
*/
コード例 #14
0
<?php

require_once "XML_PullParser.inc";
$tags = array("entry");
$child_tags = array("server", "ipaddress", "domain");
$parser = new XML_PullParser("DNS.xml", $tags, $child_tags);
while ($token = $parser->XML_PullParser_getToken()) {
    $parser->XML_PullParser_getElement('server');
    $which = 1;
    while ($server = $parser->XML_PullParser_getText('server', $which)) {
        $ip = $parser->XML_PullParser_getAttributes('server', $which);
        echo "Name: {$server}\n";
        echo "\tIP: " . $parser->XML_PullParser_getAttrVal('ip', $ip) . "\n";
        $which++;
    }
}
/*
  Result
    Name:  example_1.com
        IP: 192.168.10.1
    Name:  example_2.com
        IP: 192.168.10.2
    Name:  example_3.com
        IP: 192.168.10.3
*/