xml010.phpt 916 B

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