NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP4 Array/XML sorting question

Peter Sawczynec ps at pswebcode.com
Tue Apr 11 15:02:06 EDT 2006


For reference, here is a 3-pack zipped download that contains a working XSLT
task sample:
http://www.pswebcode.com/samples/XML-XSLTSample.zip

This task reads apartment listings from an XML file, sorts them by price and
displays them on a complete XHTML page.

The files included are:

listings_list.php
[A PHP file that transforms an XML file with an XSL file.]
listings_list.xml
[A very short demo XML data file.]
listings_list.xsl
[A complete XSLT file containing sample XHTML, CSS and XSL that transforms
the XML.]

Warmest regards,

Peter Sawczynec,
Technology Director
PSWebcode
_Design & Interface
_Ecommerce
_Database Management
ps at pswebcode.com
718.796.1951
www.pswebcode.com



-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Tim Boyden
Sent: Tuesday, April 11, 2006 1:29 PM
To: talk at lists.nyphp.org
Subject: [nycphp-talk] PHP4 Array/XML sorting question


Hello,

I am working on a web page that lists some ads stored in an XML file and I'm
having trouble with figuring out how to sort the listings by their
"category" element. Currently I pull the "ad" elements from the XML into an
array and print out the HTML list of ads in a non-sorted manner. I'd like it
to print out with a header for the category followed by a list of ads in
that category. I'm not sure how to code it though. Any help would be
appreciated. Below is a snippet from the XML file:

<?xml version="1.0" encoding="iso-8859-1"?>
<ads>
<ad>
    <franchise>test</franchise>
    <category>Food</category>
    <title>Test 1</title>
    <url>testpage1.pdf</url>
</ad>
<ad>
    <franchise>test</franchise>
    <category>Home Improvement</category>
    <title>Test 2</title>
    <url>testpage2.pdf</url>
</ad>
<ad>
    <franchise>test</franchise>
    <category>Services</category>
    <title>Test 3</title>
    <url>testpage3.pdf</url>
</ad>
</ads>

Thanks,

Tim Boyden

--------------------------- 
Timothy Boyden 
Network Administrator 
tboyden at supercoups.com 
  
SuperCoupsR | 350 Revolutionary Drive | E. Taunton, MA 02718 
508-977-2034  | www.supercoups.com 
--------------------------- 
Local Coupons. Super Savings.R




More information about the talk mailing list