[Tutor] XML Programs

Stefan Behnel stefan_ml at behnel.de
Tue Apr 17 14:56:03 EDT 2018


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



More information about the Tutor mailing list