This book is really torture. I saw the XML parsing part today. The article was very careful in introducing the functions and their parameters. However, this book did not write the source code clearly. There is always a missing part. XML and PHP are not very case sensitive. I'm sensitive and can read it all. I also encountered a garbled code problem today. I hope that a master in this field can see it and help solve it. Thank you very much! The code in the book is posted below:
function start($parser,$element_name,$element_attrs)
{
switch($element_name)
{
case "Book":
echo " ----Book introduction----
"; //The content of this paragraph is not displayed either
break;
case "TITLE":
echo "Book name:";
break ;
case "AUTHOR":
echo "Author:";
break;
case "ISBN":
echo "ISBN:";
break;
case "DATA":
echo "Publication date:";
break;
case "PRICE":
echo "Book price:";
break;
}
}
function stop($parser,$element_name)
{
echo "
";
}
function char( $parser,$data)
{
echo $data;
}
$parser=xml_parser_create();
xml_set_element_handler($parser,"start","stop");
xml_set_character_data_handler($parser,"char");
$fp=fopen("Book.xml","r");
while($data=fread($fp,4096))
{
xml_parse($parser,$data,feof($fp)) or
die (sprintf("XML Error: %s at line %d",
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser)));
}
xml_parser_free($parser);
?>
Book. The xml code is as follows:
2012.9< /DATA>
The above introduces the "Flex+PHP RIA Application Development Practical Detailed Explanation - Liang Wen New Edition" learning diary 2, including the content, I hope it will be helpful to friends who are interested in PHP tutorials.