I have a smple xml

D

David Cox

<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 ?
 
J

Joe Kesselman

David said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top