]> granicus.if.org Git - php/commitdiff
test for attributes
authorChristian Stocker <chregu@php.net>
Mon, 23 Feb 2004 15:55:16 +0000 (15:55 +0000)
committerChristian Stocker <chregu@php.net>
Mon, 23 Feb 2004 15:55:16 +0000 (15:55 +0000)
ext/xml/tests/xml010.phpt [new file with mode: 0644]

diff --git a/ext/xml/tests/xml010.phpt b/ext/xml/tests/xml010.phpt
new file mode 100644 (file)
index 0000000..962aad3
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+XML parser test, attributes
+--FILE--
+<?php
+function start_elem($parser,$name,$attribs) {
+       print "$name ";
+    
+    foreach($attribs as $key => $value) {
+        print "$key = $value ";
+    }
+    print "\n";
+}
+function end_elem()
+{
+}
+
+$xml = <<<HERE
+<a xmlns="http://example.com/foo"
+    xmlns:bar="http://example.com/bar">
+  <bar:b foo="bar"/>
+  <bar:c bar:nix="null" foo="bar"/>
+</a>
+HERE;
+
+$parser = xml_parser_create_ns("ISO-8859-1","@");
+xml_set_element_handler($parser,'start_elem','end_elem');
+xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+xml_parse($parser, $xml);
+xml_parser_free($parser);
+?>
+--EXPECT--
+http://example.com/foo@a 
+http://example.com/bar@b foo = bar 
+http://example.com/bar@c http://example.com/bar@nix = null foo = bar