source: TI02-CSML/trunk/csml/Examples/Parsing/basictest.py @ 3295

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/Examples/Parsing/basictest.py@3295
Revision 3295, 740 bytes checked in by domlowe, 12 years ago (diff)

Added optional file keyword to Dataset init method. Added toPrettyXML() method.

Line 
1"""Test for CSML parsing code
2"""
3
4import csml
5
6#Name of test file
7f='example.xml'
8
9#Create empty dataset object and parse the file,f into it.
10#This creates a new CSML document string from the CSML objects in memory:
11dataset=csml.parser.Dataset(file=f)
12
13#or the long way:
14#dataset=csml.parser.Dataset()
15#dataset.parse(f)
16
17#Now output the CSML from the dataset object.
18#Hopefully the CSML output should be the same as the CSML it read in:
19
20#the toXML() method returns an elementtree element instance:
21csmldoc = dataset.toXML()
22print csmldoc
23
24#And the toPrettyXML() method returns a string, with correct formatting and namespaces.
25#Tidy up and print the CSML document:
26strCSML=dataset.toPrettyXML()
27print strCSML
28
Note: See TracBrowser for help on using the repository browser.