Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3724444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:38:35+00:00 2026-05-19T06:38:35+00:00

I have XML data such as: <feed> <entry> <id>4</id> <updated>2011-01-18T16:55:54Z</updated> <title>title2</title> </entry> <entry> <id>3</id>

  • 0

I have XML data such as:

<feed>
  <entry>
    <id>4</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title2</title>
  </entry>
  <entry>
    <id>3</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title1</title>
  </entry>
  <entry>
    <id>2</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title1</title>
  </entry>
  <entry>
    <id>1</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title</title>
  </entry>
</feed>

And I need the outcome to result like:

<feed>
  <entry>
    <id>1</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title</title>
  </entry>
  <entry>
    <id>2</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title1</title>
  </entry>
  <entry>
    <id>3</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title1</title>
  </entry>
  <entry>
    <id>4</id>
    <updated>2011-01-18T16:55:54Z</updated>
    <title>title2</title>
  </entry>
</feed>

Basically I need the XSLT to sort on the title, then the ID. I have made an XSLT but the shorter times come out last (using Xerces):

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

 <xsl:template match="@* | node()">
  <xsl:copy>
   <xsl:apply-templates select="@* | node()" />
  </xsl:copy>
 </xsl:template>

 <xsl:template match="atom:feed">
  <xsl:copy>
   <xsl:apply-templates select="*" />
   <xsl:for-each select="atom:entry">
    <xsl:sort select="string-length(atom:title)" order="descending" />
    <xsl:sort select="atom:title" data-type="text" order="ascending" />
    <xsl:copy-of select="."/>
   </xsl:for-each>
  </xsl:copy>
 </xsl:template>

 <xsl:template match="atom:feed/atom:entry"/>

</xsl:stylesheet>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T06:38:36+00:00Added an answer on May 19, 2026 at 6:38 am

    For your input sample (not actually an Atom feed), this stylesheet:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()" />
            </xsl:copy>
        </xsl:template>
        <xsl:template match="feed">
            <xsl:copy>
                <xsl:apply-templates>
                    <xsl:sort select="update" order="descending"/>
                    <xsl:sort select="title"/>
                    <xsl:sort select="id" data-type="number"/>
                </xsl:apply-templates>
            </xsl:copy>
        </xsl:template>
    </xsl:stylesheet>
    

    Output:

    <feed>
        <entry>
            <id>1</id>
            <updated>2011-01-18T16:55:54Z</updated>
            <title>title</title>
        </entry>
        <entry>
            <id>2</id>
            <updated>2011-01-18T16:55:54Z</updated>
            <title>title1</title>
        </entry>
        <entry>
            <id>3</id>
            <updated>2011-01-18T16:55:54Z</updated>
            <title>title1</title>
        </entry>
        <entry>
            <id>4</id>
            <updated>2011-01-18T16:55:54Z</updated>
            <title>title2</title>
        </entry>
    </feed>
    

    Note: This date time format can be ordered like string (default) as long as there is no different time zone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the xml/html data to post we need to encode the data
I have an issue. I have hierarchical XML data such as: <Tree> <Node Text=Stuff
I have some xml data contained in three files (Database.xml, Participants.xml, and ConditionTokens.xml). I
I have an xml data file and I want to populate a listview in
I have an xml file providing data for a datagrid in Flex 2 that
I have to import some XML data into my app. Now I open a
I have a single xml document (data.xml), which I display as HTML using an
I have a XML Document (LessonData.xml) with lesson data in it, with the following
I have a DataSet consisting of XML data, I can easily output this to
I have a httpservice that returns xml data. <mx:HTTPService id=httpService url=data/Software.xml resultFormat=e4x result=httpResult_handler(event) fault=Alert.show('XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.