General discussion

Locked

XML QUESTION

By elrey103 ·
My friend is looking for how to do something in XML - here's what he wrote......
he knows XML fairly well - but can't figure out for the life of him how to get it to ALPHABITZE the stuff...
There are lots of tutorials and stuff that assume he knows too much already apparently....
Please write a complete script that will pull the data from the following XML database and list the names in alphabetical order and display it on a webpage


<company>
<employee>
<name>Ed</name>
</employee>
<employee>
<name>Jeremy</name>
</employee>
<employee>
<name>Frank</name>
</employee>
</company>

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Jaqui In reply to XML QUESTION

I would recommend your friend uses a perlscript cgi for the sorting, have it send it as the xml.
xml is more markup than data manipulation, designed for layout.
a scripting language has the tools for a sort already.
I'm not sure it's possible to run a sort in a layout language.

Collapse -

by grantwparks In reply to XML QUESTION

If you an XSL transform facility available you can use XSL stylesheet:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="yes" />

<xsl:template match="/company">
<html>
<head>
</head>
<body>
<h3>Unsorted</h3>
<xsl:apply-templates select="employee" />
<h3>Sorted by name</h3>
<xsl:apply-templates select="employee">
<xsl:sort select="name"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="employee">
<p><xsl:value-of select="name"/></p>
</xsl:template>
</xsl:stylesheet>

Collapse -

by Sara L In reply to XML QUESTION

Data is coming from a database, right? Can't you just use an ORDER BY clause in the SQL statement?

Just a thought.

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums