I have a smple xml

Discussion in 'XML' started by David Cox, Dec 10, 2006.

  1. David Cox

    David Cox Guest

    <root >
    <employee id="111">Douglas</employee>
    <wife n="1">Kitty</wife>
    <kid no="1">Polo</kid>
    <kid no="2">Paolo</kid>
    <wife num="2">Peck</wife>
    <kid no="1">Poke</kid>

    <employee id="000">Jitto</employee>
    <wife n="1">Kitten</wife>
    <kid no="1">Po</kid>
    </root>

    I'd like to sort them outputing into 2 ways, sort by id, sort by name
    of the emploee and in each sort, the subchilds also get sorted by
    number and by name.
    How can i do this ?
     
    David Cox, Dec 10, 2006
    #1
    1. Advertising

  2. David Cox wrote:
    > I'd like to sort them outputing into 2 ways, sort by id, sort by name
    > of the emploee and in each sort, the subchilds also get sorted by
    > number and by name.
    > How can i do this ?


    First thing you want to do is fix your markup so you're consistant about
    whether the numbering attribute is called "num", "no", "n", or something
    else. The machine can't read your mind, and you really don't want to
    waste effort trying to explain that these all have the same intent.

    You also probably want to fix the hierarchy so each <employee> element
    contains the related <wife> elements, and each <wife> contains its
    related <kid>s, rather than merely being followed by them. Indentation
    is not semantically useful; containment is.


    After fixing your document design problems, I'd suggest an XSLT
    stylesheet; this is a very standard application thereof.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Dec 11, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?cmdyYW5kaWRpZXI=?=

    Can I have base class derived from System.Web.UI.Page have design

    =?Utf-8?B?cmdyYW5kaWRpZXI=?=, Jul 22, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    507
    Patrice
    Jul 22, 2005
  2. okaminer
    Replies:
    3
    Views:
    313
    okaminer
    Aug 1, 2005
  3. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    6
    Views:
    5,546
    Kevin Spencer
    Aug 18, 2005
  4. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    Does a resource have to have all phrases in it?

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Jan 30, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    389
    Neil Ni
    Feb 3, 2006
  5. Erik Wasser
    Replies:
    5
    Views:
    517
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page