예제 #1
0

<?php 
require_once "XML_PullParser_NS.inc";
XML_PullParser_excludeBlanks(true);
echo "<pre>\n";
$tags = array("Movie");
$child_tags = array('date');
$parser = new XML_PullParser_NS("Movies.xml", $tags, $child_tags);
$parser->XML_PullParser_setCurrentNS("http://room535.org/movies/xtitle/|" . "http://room535.org/movies/mov/|http://room535.org/movies/star/|http://room535.org/movies/dates/");
while ($token = $parser->XML_PullParser_getToken()) {
    // since XML_PullParser_getElement has not been called
    // XML_PullParser_setAttrLoop_elcd will use $token
    $attr_vals = $parser->XML_PullParser_setAttrLoop_elcd();
    while ($at = $parser->XML_PullParser_nextAttr()) {
        if ($at[2]) {
            echo "{$at['0']}: {$at['2']}\n";
        }
        foreach ($at[1] as $attr_name => $attr_value) {
            $name = "";
            if (preg_match('/DAY/i', $attr_name)) {
                $name = "day";
            }
            if (preg_match('/month/i', $attr_name)) {
                $name = "month";
            }
            if ($name) {
                echo "{$name}:  " . $parser->XML_PullParser_getAttrVal($name, $at[1]) . "\n";
            }
            if ($at[0] == 'LEADING_MAN') {
                echo "\n";
예제 #2
0

<?php 
require_once "XML_PullParser_NS.inc";
XML_PullParser_excludeBlanks(true);
XML_PullParser_trimCdata(true);
XML_PullParser_excludeBlanksStrict(true);
$tags = array("Movie");
$child_tags = array();
$parser = new XML_PullParser_NS("Movies.xml", $tags, $child_tags);
$parser->XML_PullParser_setCurrentNS("http://room535.org/movies/title/|" . "http://room535.org/movies/mov/|http://room535.org/movies/star/|http://room535.org/movies/dates/");
echo "<pre>\n<h2>XML_PullParser_getAttrValues</h2>\n";
while ($token = $parser->XML_PullParser_getToken()) {
    $attr_vals = $parser->XML_PullParser_setAttrLoop_elcd($token);
    while ($_ns_ = $parser->XML_PullParser_nextAttr()) {
        if ($_ns_[0] == 'DATE') {
            $month = $parser->XML_PullParser_getAttrVal('month', $_ns_[1]);
            $day = $parser->XML_PullParser_getAttrVal('day', $_ns_[1]);
            echo $_ns_[0] . " {$month} {$day} " . $_ns_[2] . "\n";
        } else {
            echo $_ns_[0] . " " . $_ns_[2] . "\n";
        }
    }
    echo "\n";
}
echo "</pre>\n";
/*
Result
This missing items in these results occur where there is no namespace qualifying the element or attribute.

MOVIE