Приглашаем посетить
Мамин-Сибиряк (mamin-sibiryak.lit-info.ru)

11.4 Exercises

Previous Table of Contents Next

11.4 Exercises

  1. Using the XML document in the $menu variable defined in Example 11-5, print an HTML <ul> list in which each list element is the <title> of one <item> in the XML document, and that <title> is hyperlinked to the URL listed in the <link> element of the item. For example, if one of the items were:

    <item>
    
     <title>Steamed Rock Cod</title>
    
     <link>http://menu.example.com/dishes.php?dish=cod</link>
    
     <description>Enjoy a cod, bursting with flavor.</description>
    
    </item>

    Then the corresponding list element that your code prints would be:

    <li><a href="http://menu.example.com/dishes.php?dish=cod">Steamed Rock Cod</a>
    
         </li>

  2. Write a program that prints a form asking for a user to input an RSS item title, link, and description. Make sure the user enters something for each field. Use the submitted form data to print an XML document consisting of a one-item RSS feed. Define the <channel> part of the feed in your program (you don't have to gather form input for it). Make sure to use header( ) and htmlentities( ) to produce a valid XML response.

  3. Modify your answer to Exercise 7.2 so that the output of the program is an XML document. Structure your output like Example 11-18—put the information about each dish inside <dish></dish> tags, and put all the <dish></dish> tags inside <dishes></dishes> tags.

  4. Write a program that prints a form asking for a user to input a search term. Retrieve an RSS news feed (such as one listed at http://news.yahoo.com/rss/) and display a list of links to items in the news feed that have the search term in the item title. Format each list element the same way as Exercise 11.1. To find matching news titles, you can use a regular expression or a function such as stristr( ).

    Previous Table of Contents Next