Re: [Tutor] XML Programs

2018-04-17 Thread Stefan Behnel
leam hall schrieb am 16.04.2018 um 14:54:
> On Mon, Apr 16, 2018 at 7:10 AM, Glen wrote:
>> I'm writing a save-game editor for a game I play (just a project to learn).
>> But I am struggling on how to structure the code, how to store the xml data
>> in data structure etc,
>>
>> Can anyone recommend some source I can review that reads and writes data
>> from an xml file.
> 
> A friend's comment was "life is too short for XML". I like that. Have
> you considered JSON? Taking it a step further, MongoDB (JSON) or
> SQLite (SQL)? Both are pretty common and standard.

Actually, XML is pretty common and standard. But life's definitely too
short for Mongo.

Stefan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] XML Programs

2018-04-17 Thread Stefan Behnel
Glen schrieb am 16.04.2018 um 13:10:
> I'm writing a save-game editor for a game I play (just a project to learn).
> But I am struggling on how to structure the code, how to store the xml data
> in data structure etc,
> 
> Can anyone recommend some source I can review that reads and writes data
> from an xml file.

Here's a tutorial for the lxml package:

http://lxml.de/tutorial.html

However, I'd first check if there really is no Python library yet that
handles your "game files", whatever format they may have. One of the most
important things to learn about software engineering is to know when *not*
to write code to solve a problem.

If you end up having (or wanting) to deal with the bare XML format
yourself, you may consider implementing your own XML API for your format,
so that you can nicely assign functionality to certain tags in the document
tree. See the section on "Implementing Namespaces" here:

http://lxml.de/element_classes.html

Stefan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor