sasKuatch
10-14-2003, 01:57 PM
Hello,
I have an XML file with many, many elements in it. There are two levels (ie, in the root there are many elements, and each element has many under it). The lowest element has a list of a few elements in it.
It's from the game Vegastrike (vegastrike.sourceforge.net). The file is huge, 2.2 megs or so. I counted 59 sectors, and 5706 systems divided up among the sectors.
Many users are complaining of being lost, and I would like to help by writing a script that can take the origin (current location) and destination (desired location) as arguments, and print a route between the two systems. So if a user types in Beckett/Cain as the origin and Izzptipt/Hubble as the destination, the program would print out
Beckett/Cain
Beckett/Goddard
Izzptipt/Hubble
This is just a simple example, but you get the idea.
My Question How do I search through this many entries? Is it realistic for the computer to do? If so, how? Please help me, I'm having trouble wrapping my brain around this.
Languages Preferably Java or Python, though C/C++ is a choice as well. However, I'm mostly in need of an algorithm to search through this monster.
Snippet of XML
<galaxy><systems>
<sector name="Aantlbzz">
<system name="Aanpzezyqqh">
<var name="data" value="-1732746283"/>
<var name="faction" value="rlaan"/>
<var name="luminosity" value="0"/>
<var name="num_gas_giants" value="2"/>
<var name="num_moons" value="0"/>
<var name="num_natural_phenomena" value="0"/>
<var name="num_planets" value="1"/>
<var name="planetlist" value="planets.rlaan.txt"/>
<var name="sun_radius" value="16600.000000"/>
<var name="xyz" value="1168.837048 -267.182908 -256.453328"/>
<var name="jumps" value="Aantlbzz/Bzzzahb Aantlbzz/Tlaanbzz Aantlbzz/Azzyqqhzeen Pzzaztahber/Tl Aantlbzz/Zyqqhazz"/>
</system>
<system name="Aantkyqqh">
<var name="data" value="1418924545"/>
<var name="faction" value="rlaan"/>
<var name="luminosity" value="0"/>
<var name="num_gas_giants" value="0"/>
<var name="num_moons" value="1"/>
<var name="num_natural_phenomena" value="0"/>
<var name="num_planets" value="2"/>
<var name="planetlist" value="planets.rlaan.txt"/>
<var name="sun_radius" value="16600.000000"/>
<var name="xyz" value="1008.112031 -326.697561 -217.614905"/>
<var name="jumps" value="Aantlbzz/Ahbaantk Pzzaztahber/Azzkabazz Bztutpt/Zeenazzzeen Pzzaztahber/Zyqqhtk Aantlbzz/Izzazztl"/>
</sector>
</systems></galaxy>
An example of output from my script would be:
Ohzzz/Zeenaanzeen
Ohzzz/Ahbpzezyqqh
Ohzzz/Ahbbzztl
Eebzpt/Aantltk
Eebzpt/Tlaanzeen
Bzzahbtktk/Zbzztl
Bzzahbtktk/Pzezptzeen
Bzzahbtktk/Bzzptpzez
Bribztkaber/Yqqhtkyqqh
Bribztkaber/Pzeztkpzez
Bribztkaber/Pttk
Crucible/Agea
Crucible/War
Magellan/Steakley
Magellan/Theta_Ant
Magellan/Tcsc_1613
Sol/Hhrass
Sol/Ktrk_pah
Vega/Adityas
Sol/Visvedevas
Sol/Parjanya
Sol/max
Sol/Alcestis
Sol/Sol
I have an XML file with many, many elements in it. There are two levels (ie, in the root there are many elements, and each element has many under it). The lowest element has a list of a few elements in it.
It's from the game Vegastrike (vegastrike.sourceforge.net). The file is huge, 2.2 megs or so. I counted 59 sectors, and 5706 systems divided up among the sectors.
Many users are complaining of being lost, and I would like to help by writing a script that can take the origin (current location) and destination (desired location) as arguments, and print a route between the two systems. So if a user types in Beckett/Cain as the origin and Izzptipt/Hubble as the destination, the program would print out
Beckett/Cain
Beckett/Goddard
Izzptipt/Hubble
This is just a simple example, but you get the idea.
My Question How do I search through this many entries? Is it realistic for the computer to do? If so, how? Please help me, I'm having trouble wrapping my brain around this.
Languages Preferably Java or Python, though C/C++ is a choice as well. However, I'm mostly in need of an algorithm to search through this monster.
Snippet of XML
<galaxy><systems>
<sector name="Aantlbzz">
<system name="Aanpzezyqqh">
<var name="data" value="-1732746283"/>
<var name="faction" value="rlaan"/>
<var name="luminosity" value="0"/>
<var name="num_gas_giants" value="2"/>
<var name="num_moons" value="0"/>
<var name="num_natural_phenomena" value="0"/>
<var name="num_planets" value="1"/>
<var name="planetlist" value="planets.rlaan.txt"/>
<var name="sun_radius" value="16600.000000"/>
<var name="xyz" value="1168.837048 -267.182908 -256.453328"/>
<var name="jumps" value="Aantlbzz/Bzzzahb Aantlbzz/Tlaanbzz Aantlbzz/Azzyqqhzeen Pzzaztahber/Tl Aantlbzz/Zyqqhazz"/>
</system>
<system name="Aantkyqqh">
<var name="data" value="1418924545"/>
<var name="faction" value="rlaan"/>
<var name="luminosity" value="0"/>
<var name="num_gas_giants" value="0"/>
<var name="num_moons" value="1"/>
<var name="num_natural_phenomena" value="0"/>
<var name="num_planets" value="2"/>
<var name="planetlist" value="planets.rlaan.txt"/>
<var name="sun_radius" value="16600.000000"/>
<var name="xyz" value="1008.112031 -326.697561 -217.614905"/>
<var name="jumps" value="Aantlbzz/Ahbaantk Pzzaztahber/Azzkabazz Bztutpt/Zeenazzzeen Pzzaztahber/Zyqqhtk Aantlbzz/Izzazztl"/>
</sector>
</systems></galaxy>
An example of output from my script would be:
Ohzzz/Zeenaanzeen
Ohzzz/Ahbpzezyqqh
Ohzzz/Ahbbzztl
Eebzpt/Aantltk
Eebzpt/Tlaanzeen
Bzzahbtktk/Zbzztl
Bzzahbtktk/Pzezptzeen
Bzzahbtktk/Bzzptpzez
Bribztkaber/Yqqhtkyqqh
Bribztkaber/Pzeztkpzez
Bribztkaber/Pttk
Crucible/Agea
Crucible/War
Magellan/Steakley
Magellan/Theta_Ant
Magellan/Tcsc_1613
Sol/Hhrass
Sol/Ktrk_pah
Vega/Adityas
Sol/Visvedevas
Sol/Parjanya
Sol/max
Sol/Alcestis
Sol/Sol