Thread: Read XML file

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    2
    Rep Power
    0

    Read XML file


    Hi!
    I tryed to read an XML file and to store the data such as nodes and values in the dictionary. I know that dictionary is unordered siquence. I can not use tuple because I have add more from another file later on.

    Does anybody know what I should use in order to have it stored in the some kind of container in the same order that it is in XML file?

    Thanks.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,616
    Rep Power
    4247
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    On the subject of what types to use for containers i'd probably go for a mix of list and dictionaries. This way you can use the list to keep the nodes/groups ordered and then use dictionary to store the different node names i.e.

    Code:
    nodes = [{'name1': 'value', 'name2': 'value'}, {'name1': 'value', 'name2': 'value'}] and so on...
    from an XML doc something like this:

    Code:
    <group>
        <name1>value</name1>
        <name2>value</name2>
    </group>
    <group>
        <name1>value</name1>
        <name2>value</name2>
    </group>
    Note: none of this is ment to work i'm simply trying to explain the basic idea...

    Hope this is of some help,

    Mark.
    Last edited by netytan; February 23rd, 2004 at 06:09 PM.
    programming language development: www.netytan.com Hula

  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    2
    Rep Power
    0
    Thanks to all. It worked.

IMN logo majestic logo threadwatch logo seochat tools logo