xref: /PHP-5.4/ext/xml/tests/xml010.phpt (revision 97200944)
1--TEST--
2XML parser test, attributes
3--SKIPIF--
4<?php
5require_once("skipif.inc");
6if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");}
7?>
8--FILE--
9<?php
10function start_elem($parser,$name,$attribs) {
11	print "$name ";
12
13    foreach($attribs as $key => $value) {
14        print "$key = $value ";
15    }
16    print "\n";
17}
18function end_elem()
19{
20}
21
22$xml = <<<HERE
23<a xmlns="http://example.com/foo"
24    xmlns:bar="http://example.com/bar">
25  <bar:b foo="bar"/>
26  <bar:c bar:nix="null" foo="bar"/>
27</a>
28HERE;
29
30$parser = xml_parser_create_ns("ISO-8859-1","@");
31xml_set_element_handler($parser,'start_elem','end_elem');
32xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
33xml_parse($parser, $xml);
34xml_parser_free($parser);
35?>
36--EXPECT--
37http://example.com/foo@a
38http://example.com/bar@b foo = bar
39http://example.com/bar@c http://example.com/bar@nix = null foo = bar
40