Logo         Community
The Company
Your Account
Contact Us
Injecting XML Content Into Page Templates With patXMLRenderer (part 2)
Cache content, log activities and report usage with patXMLRenderer

| Meet Moo |

Thus far, I've only dealt with XML files containing elements. But what if your XML elements include  attributes...and those attribute values need to appear in your rendered output?

Fear not, patXMLRenderer has you covered there too. The package automatically maps element attributes into template variables, automatically replacing placeholders with corresponding attribute values in the call to displayRenderedContent(). Consider the following example, which illustrates by placing a boatload of information about Timothy into attributes:

<?xml version="1.0"?>
<person age="18" ssn="A736AS957" location="NY">Timothy Moo</person>

And here's the corresponding template - notice how the attribute names from the XML data above map into the template variables:

<!-- main page -->
<patTemplate:tmpl name="person">
My name is {CONTENT}. I am {AGE} years old, located in {LOCATION} and my Social Security number is {SSN}. Drop by and meet me when you have a minute. Bye now!

When you combine the two, the output looks like this:

''.preg_replace(array('/  /', '/ /'), array('  ', '   '), '
My name is Timothy Moo. I am 18 years old, located in NY and my Social Security number is A736AS957. Drop by and meet me when you have a minute. Bye now!

Cool, huh?

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback