Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/Examples/Parsing/basictest.py@3296
Revision 3296,
730 bytes
checked in by domlowe, 13 years ago
(diff) |
fixing example parser and point series subsetting of inline content
|
Line | |
---|
1 | """Test for CSML parsing code |
---|
2 | """ |
---|
3 | |
---|
4 | c |
---|
5 | |
---|
6 | #Name of test file |
---|
7 | f='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: |
---|
11 | dataset=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: |
---|
21 | csmldoc = dataset.toXML() |
---|
22 | print csmldoc |
---|
23 | |
---|
24 | #And the toPrettyXML() method returns a string, with correct formatting and namespaces. |
---|
25 | #Tidy up and print the CSML document: |
---|
26 | strCSML=dataset.toPrettyXML() |
---|
27 | print strCSML |
---|
28 | |
---|
Note: See
TracBrowser
for help on using the repository browser.