<?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/title/|" . "http://room535.org/movies/mov/|http://room535.org/movies/star/|http://room535.org/movies/dates/"); echo "\n<h2>\$parser->XML_PullParser_nextElement</h2>\n"; while ($token = $parser->XML_PullParser_getToken()) { $date = $parser->XML_PullParser_getElement('date'); while ($_ns_ = $parser->XML_PullParser_nextElement()) { $attr_array = $parser->XML_PullParser_getAttributes($_ns_); $text = $parser->XML_PullParser_getAttrVal('month', $attr_array); echo "Month: {$text}\n"; } } echo "\n</pre>\n"; /* Result The scond month is missing because the month for How Green Was My Valley is not qualfied by a namespace Month: Apr Month: Month: June */
<?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/title/|" . "http://room535.org/movies/mov/|http://room535.org/movies/star/|http://room535.org/movies/dates/"); while ($token = $parser->XML_PullParser_getToken()) { $title = $parser->XML_PullParser_getText('title'); $leading_man = $parser->XML_PullParser_getText('leading_man'); $leading_lady = $parser->XML_PullParser_getText('leading_lady'); $year = $parser->XML_PullParser_getText('date'); $attr_array = $parser->XML_PullParser_getAttributes('date'); $month = $parser->XML_PullParser_getAttrVal('month', $attr_array); $day = $parser->XML_PullParser_getAttrVal('day', $attr_array); echo "Title: {$title}\n"; echo "Date: {$month} {$day} {$year}\n"; echo "Leading Lady: {$leading_lady}\n"; if ($leading_man) { echo "Leading Man: {$leading_man}\n"; } echo "\n\n"; exit; } echo "\n</pre>\n"; /* Result Title: Gone With The wind