|
-
February 28th, 2010, 03:39 PM
#1
Pyxml generate Schema *HELP!!*
Hi all, I don't know if this is in the right place but I am still rather green at XML stuff.
I've been looking at xml and want to make a python program that can generate the xml schema instead of typing out the whole schema by hand. As far as I have seen, I need the pyxml program installed for the xml schema generation to work.
I have made a simple xml doc based on the L4D2 game for trials:
Code:
<Left_4_Dead_2>
<Game_content>
<characters>
<player_characters>Ellis</player_characters>
<player_characters>Rochelle</player_characters>
<player_characters>Coach</player_characters>
<player_characters>Nick</player_characters>
<Infected>Tank</Infected>
<Infected>Witch</Infected>
<Infected>Hunter</Infected>
<Infected>Smoker</Infected>
<Infected>Boomer</Infected>
<Infected>Spiter</Infected>
<Infected>Jocky</Infected>
<Infected>Charger</Infected>
<Infected>General</Infected>
</characters>
<Items>
<aid>medpack</aid>
<aid>pills</aid>
<aid>Adrenaline shot</aid>
<Melee_Weapons>Machete</Melee_Weapons>
<Melee_Weapons>Guitar</Melee_Weapons>
<Melee_Weapons>Frying Pan</Melee_Weapons>
<Melee_Weapons>Nightstick</Melee_Weapons>
<Volatile>Pipe Bombs</Volatile>
<Volatile>Molitovs</Volatile>
<Volatile>Boomer Bile</Volatile>
<Ranged_Weapons>
<Close_range>Shotgun</Close_range>
<Close_range>Auto Shotgun</Close_range>
<long_range>Sub-machine gun</long_range>
<long_range>Machine gun</long_range>
<long_range>AK47</long_range>
<long_range>Pistol</long_range>
<long_range>Rifle</long_range>
</Ranged_Weapons>
<Ammo>Normal</Ammo>
<Ammo>Ignitable</Ammo>
</Items>
</Game_content>
</Left_4_Dead_2>
Looking into other information I have made a very rough section of code to start with but I need a lot of help finishing it:
Code:
from xml.SAX import make_parser
from xml.SAX.handler import ContentHandler
class l4d2Handler(ContentHandler):
def __init__ (self,searchTerm):
///////////////////////////////
///////////////////////////////
def startElement:
return
def endElement:
return
make_parser()
parser=parse(open('xmldoc.xml'))
where I've put ////// i know there should be something more there, the code is made of pieces from tutorials I found that didn't explain enough to complete the program, and this is what I have made.
I really need some help with this, and I need to complete it asap
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|