xml010.phpt 927 B

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