Commit 10b6170877efafa44b201ccd00e318e7fc99373e

Authored by Jürgen Knödlseder
1 parent 0c13d110

Rename xml_create.py to xml_howto.py

examples/python/xml_create.py renamed to examples/python/xml_howto.py
... ... @@ -6,11 +6,11 @@
6 6 # with GammaLib
7 7 #
8 8 # Usage
9   -# ./xml_create.py
  9 +# ./xml_howto.py
10 10 #
11 11 # -------------------------------------------------------------------------
12 12 #
13   -# Copyright (C) 2012 Juergen Knoedlseder
  13 +# Copyright (C) 2013 Juergen Knoedlseder
14 14 #
15 15 # This program is free software: you can redistribute it and/or modify
16 16 # it under the terms of the GNU General Public License as published by
... ... @@ -35,7 +35,7 @@ from math import *
35 35 # =================== #
36 36 def create_xml():
37 37 """
38   - Create XML document example.
  38 + Illustrates the creation of an XML document.
39 39  
40 40 This function creates a simple XML document that illustrates how an
41 41 XML document can be constructed with GammaLib. In this example, the
... ... @@ -90,7 +90,7 @@ def create_xml():
90 90 # ======================= #
91 91 def manipulate_xml(xml):
92 92 """
93   - Example for manipulating an XML document.
  93 + Illustrates the manipulation of an XML document.
94 94  
95 95 This function illustrates the manipulation of an XML document by
96 96 using the remove(), insert(), set() and extend() methods.
... ... @@ -187,6 +187,23 @@ def manipulate_xml(xml):
187 187 return xml
188 188  
189 189  
  190 +# ================ #
  191 +# XML document I/O #
  192 +# ================ #
  193 +def xml_io(xml):
  194 + """
  195 + Illustrates input/output for an XML document.
  196 + """
  197 + # Save the XML document into a file
  198 + xml.save("xml_howto.xml")
  199 +
  200 + # Reload the XML document
  201 + xml.load("xml_howto.xml")
  202 +
  203 + # Return
  204 + return xml
  205 +
  206 +
190 207 # ================= #
191 208 # Show XML document #
192 209 # ================= #
... ... @@ -236,4 +253,12 @@ if __name__ == '__main__':
236 253 print("2. manipulate_xml() output")
237 254 print("==========================")
238 255 show_xml(xml)
  256 +
  257 + # Perform I/O
  258 + xml = xml_io(xml)
  259 +
  260 + # Show XML document
  261 + print("3. xml_io() output")
  262 + print("==================")
  263 + show_xml(xml)
239 264  
240 265 \ No newline at end of file
... ...