SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2000
    Location
    Casablanca, Morocco
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sorting XML nodes

    Take this example
    Code:
    <person>
      <name>foo</name>
      <diploma>something<diploma>
      <skill>some skill</skill>
    <person>
    After some years the guy evoluated and we appended some nodes to his xml file. So now we have
    Code:
    <person>
      <name>foo</name>
      <diploma>something<diploma>
      <skill>some skill</skill>
      <diploma>something<diploma>
      <diploma>something<diploma>
      <skill>some skill</skill>
      <skill>some skill</skill>
    <person>
    Is there anyway to sort the nodes using asp/xmldom ?

  2. #2
    SitePoint Zealot JEmLAC's Avatar
    Join Date
    Apr 2002
    Location
    Kansas City
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML nodes

    I've only started working with XML in ASP over the last couple of months, but if I could start with a suggestion about your XML structure. Your person node is a bit hard to read and could be a bit better to look at and manipulate if you added a collection layer like:
    Code:
    <person>
      <name>foo</name>
        <education>
          <diploma>something</diploma>
          <diploma>something</diploma>
          <diploma>something</diploma>
        </education>
        <skills>
          <skill>some skill</skill>
          <skill>some skill</skill>
          <skill>some skill</skill>
        </skills>
    <person>
    As far as sorting goes, much of this type of manipulation (in my travels) is done client-side, with some script. The only example I can lay hands on in short order is too long to post here, but it is in the Javascript Bible - Gold Edition by Danny Goodman (an excellent reference by the way). Note, it's MSIE only, since it relies on xml data islands on the client.

    To my knowledge (I could be wrong), the DOM does not have any native methods for sorting. Here are few resources to look at tho'
    http://xmlpitstop.com (good tutorial section)
    http://w3schools.org (behaving weirdly when I was there)

    HIH
    B
    Morning person by habit, not by nature.

  3. #3
    SitePoint Member
    Join Date
    May 2000
    Location
    Casablanca, Morocco
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •