.htaccess example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On # Turn on the rewriting engine | |
RewriteRule ^atwd/books/(course|detail|suggestions)/([0-9]+)/(xml|json)$ http://www.cems.uwe.ac.uk/~p-chatterjee/atwd_assignment_2013/index.php?type=$1&id=$2&format=$3 [L] | |
RewriteRule ^atwd/books/.*$ http://www.cems.uwe.ac.uk/~p-chatterjee/atwd_assignment_2013/error.php [L] |
xml reader code and xml file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$reader = new XMLReader(); | |
$reader->open('../xml/quotes.xml'); | |
while ($reader->read()) { | |
if ($reader->nodeType == XMLREADER::ELEMENT) { | |
if ($reader->localName=='quote') { | |
$category[] = $reader->getAttribute("category"); | |
} | |
if ($reader->localName=='text') { | |
$reader->read(); | |
$text[] = $reader->value; | |
} | |
if ($reader->localName=='name') { | |
$reader->read(); | |
$name[] = $reader->value; | |
} | |
if ($reader->localName=='dob') { | |
$reader->read(); | |
$dob[] = $reader->value; | |
} | |
if ($reader->localName=='dod') { | |
$reader->read(); | |
$dod[] = $reader->value; | |
} | |
if ($reader->localName=='url') { | |
$reader->read(); | |
$url[] = $reader->value; | |
} | |
if ($reader->localName=='img') { | |
$reader->read(); | |
$img[] = $reader->value; | |
} | |
} | |
} | |
$count = count($category); | |
for ($i=0; $i<$count; $i++) { | |
echo '<table>'; | |
echo '<tr>'; | |
echo '<td>Category</td>'; | |
echo '<td>'.ucfirst($category[$i]).'</td>'; | |
echo '</tr>'; | |
echo '<tr>'; | |
echo '<td>Quote</td>'; | |
echo '<td>'.$text[$i].'</td>'; | |
echo '</tr>'; | |
echo '<td>Author</td>'; | |
echo '<td><a href="'.$url[$i].'">'.$name[$i].'</a></td>'; | |
echo '</tr>'; | |
echo '<td>Date</td>'; | |
echo '<td>'.$dob[$i].'-'.$dod[$i].'</td>'; | |
echo '</tr>'; | |
echo '<td>Image</td>'; | |
echo '<td><img src="'.$img[$i].'" width="200"/></td>'; | |
echo '</tr>'; | |
echo '</table>'; | |
echo '<p/>'; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<quotes> | |
<quote category='politics'> | |
<text>The great are only great because we are on our knees. Let us rise!</text> | |
<author> | |
<name>Pierre-Joseph Proudhon</name> | |
<dob>1809</dob> | |
<dod>1865</dod> | |
<url>http://en.wikipedia.org/wiki/Pierre-Joseph_Proudhon</url> | |
<img>http://upload.wikimedia.org/wikipedia/commons/e/ea/Portrait_of_Pierre_Joseph_Proudhon_1865.jpg</img> | |
</author> | |
</quote> | |
<quote category='romance'> | |
<text>Take away love and our earth is a tomb.</text> | |
<author> | |
<name>Robert Browning</name> | |
<dob>1812</dob> | |
<dod>1889</dod> | |
<url>http://en.wikipedia.org/wiki/Robert_Browning</url> | |
<img>http://upload.wikimedia.org/wikipedia/commons/4/49/Robert_Browning_1865.jpg</img> | |
</author> | |
</quote> | |
<quote category='humour'> | |
<text>It's not that I'm afraid to die, I just don't want to be there when it happens.</text> | |
<author> | |
<name>Woody Allen</name> | |
<dob>1935</dob> | |
<dod/> | |
<url>http://en.wikipedia.org/wiki/Woddy_Allen</url> | |
<img>http://upload.wikimedia.org/wikipedia/commons/0/0f/Woody_Allen_at_the_premiere_of_Whatever_Works.jpg</img> | |
</author> | |
</quote> | |
</quotes> |
No comments:
Post a Comment