"Flex+php RIA Application Development-Liang Edition" Learning Diary 2

Source: Internet
Author: User
This book is really torture Ah, today saw the XML parsing part, the article in the introduction of functions and their parameters is very careful, but this did not put the source of the final write clearly, is always a small part, XML and PHP is not very sensitive to the case, can read out, today also encountered a garbled problem, Hope this aspect of the great God saw help to solve under, greatly appreciated Ah! The code in the book is posted below:

!--? php function Start ($parser, $element _name, $element _attrs)
{
switch ($element _name)
{
Case "book":
Echo --------
"; The contents of this paragraph also do not show
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 Prices:";
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 (the 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.xml's code is as follows:





JavaScript language Essence
Crockford,d
9787121177408
2012.9
49.00 USD



The above describes the "flex+php RIA Application Development actual combat-Liang Edition" learning Diary 2, including the content of the aspects, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.