Example #1
0
 function setUp()
 {
     global $doc_DNS;
     XML_PullParser_Errors_INI();
     $this->child_tags = array("ipaddress", "server");
     XML_PullParser_NamespaceSupport(true);
     $this->parser = new XML_PullParser_doc($doc_DNS, $this->tags, $this->child_tags);
     $this->parser->XML_PullParser_setCurrentNS("http://example.com/local/|http://example.com/dns.txt/");
 }
Example #2
0
 function reInitialize($which)
 {
     global $doc;
     $this->parser->XML_PullParser_free();
     $tags['movies'] = array("Movies");
     $child_tags['movies'] = array();
     $tags['topsecret'] = array("Confidential_report");
     $child_tags['topsecret'] = array();
     XML_PullParser_NamespaceSupport(true);
     $this->parser = new XML_PullParser_doc($doc[$which], $tags[$which], $child_tags[$which]);
     $this->parser->XML_PullParser_setCurrentNS("http://example.com/local/");
 }
Example #3
0

<?php 
require_once "XML_PullParser.inc";
XML_PullParser_excludeBlanks(true);
XML_PullParser_trimCdata(true);
XML_PullParser_excludeBlanksStrict(true);
XML_PullParser_NamespaceSupport(true);
$tags = array("Movies");
$child_tags = array();
$parser = new XML_PullParser("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()) {
    $text_array = $parser->XML_PullParser_getTextArray("Title");
    print_r($text_array);
    $text_array = $parser->XML_PullParser_getTextArray('movies');
    print_r($text_array);
}
/*
Result
Notice that Sam Neil is missing, after Laura Dern.  This is because his name is not prefixed by 
a defined namespace
Array
(
    [0] => Gone With The wind
    [1] => How Green Was My Valley
    [2] => Jurassic Park
)
Array
(
    [0] => Gone With The wind
Example #4
0
 function test_setNamespaceSupport()
 {
     echo "This test should print an error messages.  It is part of the Test\n";
     $this->parser->XML_PullParser_unsetCurrentNS();
     XML_PullParser_NamespaceSupport(false);
     $retv = $this->parser->XML_PullParser_setCurrentNS("http://example.com/dns.txt/");
     if ($retv === False) {
         echo "Error check successful\n";
     }
     echo "\n";
     $this->assertEquals($retv, FALSE);
 }