:. (.. python), XML
:
, XML .
, , , .. .. - .
Python:
BeautifulSoup, lxml python (ElementTree ..) XML. XML- , XML .
(, ) python python - , . , , XML.
, :
- , XML " ", .
, , . XML, , - .
Cheetah, Jinja , .
XML, .
, .
, , , XML.
:
<?xml version="1.0"?>
<catalog>
{% for object in object_list %}
<book id="{{ object.bookID }}">
<author>{{ object.author_name }}</author>
<title>{{ object.title }}</title>
<genre>{{ object.genre }}</genre>
<price>{{ object.price }}</price>
<publish_date>{{ object.pub_date }}</publish_date>
<description>{{ object.description }}</description>
</book>
{% endfor %}
</catalog>
</xml>
The template engine will go through the "object_list" and output a long XML file with all your books. This will be much better than storing raw XML strings, as you are now.
This makes updating and changing the display of XML separate from data, storing data and manipulating data - makes your life easier.
source
share