This should work and print out the contents of the test string....
using EITHER version of the test string.

BUT, it only works when the string is one piece, and hasn't been
concatenated from other strings, at least with the contents of the
string I'm using.

Please email and let me know your version and it's behavior. Only
version 2 works for me.

<?
/* //string version 1
$test_string = 
"<?XML version=\"1.0\"?" . ">
<simple_object>
  <variable2>Crikey Mate1</variable2>
  <variable1>Crikey Mate2</variable1>
</simple_object>
";
*/

/* //string version 2
$test_string = 
"<?XML version=\"1.0\"?>
<simple_object>
  <variable2>Crikey Mate1</variable2>
  <variable1>Crikey Mate2</variable1>
</simple_object>
";
*/

echo("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<HTML>
<HEAD>
  <TITLE> test_XML_container </TITLE>
  <META NAME=\"Generator\" CONTENT=\"EditPlus\">
  <META NAME=\"Author\" CONTENT=\"\">
  <META NAME=\"Keywords\" CONTENT=\"\">
  <META NAME=\"Description\" CONTENT=\"\">
</HEAD>
<BODY BGCOLOR=\"#FFFFFF\">\n");

$indexes;
$idx=0;
$src_array;
$XML_doc;

$p = XML_parser_create();
if( false == $p ){
  echo("<br>\nNO PARSER CREATED");
} else {
  XML_parser_set_option ( $p, XML_OPTION_CASE_FOLDING , false);
  XML_parser_set_option ( $p, XML_OPTION_SKIP_WHITE   , true );

  if( XML_parse_into_struct($p,$test_string,$src_array,$indexes)) {
    XML_parser_free($p);
    print_r($src_array);
  } else {
    echo("<br>\nDID NOT PARSE CORRECTLY");
    echo("<br>\n" . $test_string );
  }
}
echo("\n</BODY>
</HTML>");
?>

Reply via email to