source: TI02-CSML/trunk/csml/csml2Moles/addnewElemTest.py @ 2112

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/csml2Moles/addnewElemTest.py@2112
Revision 2112, 1018 bytes checked in by domlowe, 13 years ago (diff)

units and missing values now working properly in subsetgridseries

Line 
1#!/usr/bin/env python
2import csml.parser
3import cElementTree
4import elementtree.ElementTree as etree
5import molesReadWrite as MRW
6
7
8def main():
9    M=MRW.MolesDoc()
10    #read in XML to python
11    tree=cElementTree.ElementTree(file='test.xml')
12    dgMeta=MRW.dgMetadata()
13    dgMeta.fromXML(tree.getroot())
14   
15    #Example of adding a new dgStructuredKeyword to an existing moles xml doc using addChildElem
16    strValidTerm='TEST 2nd kword climatologyMeteorologyAtmosphere'
17    strParentID='2 ISO 19115 - Geographic Information Metadata Topic Category Code List'
18    strTermID='2004'
19    dgVTID=M.dgValidTermID(ParentListID=strParentID, TermID=strTermID)
20    dgSK=M.dgStructuredKeyword(dgValidTerm=strValidTerm, dgValidTermID=dgVTID)
21    dgMeta.dgMetadataRecord.addChildElem('dgStructuredKeyword', dgSK)
22   
23
24
25    #regenerate XML from python
26    molestree=dgMeta.toXML()
27    moles=csml.parser_extra.PrettyPrint(molestree)
28    print '\n \n \n AFTER PARSING'
29    print moles   
30   
31if __name__=='__main__':
32    main()
Note: See TracBrowser for help on using the repository browser.