Changeset 2821

Show
Ignore:
Timestamp:
02/16/2009 01:49:08 PM (9 months ago)
Author:
tiradani
Message:

Added functionality to parse and create xml files for the OIM plugin for the GIP reports

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gip/trunk/gip/lib/python/xml_common.py

    r2247 r2821  
    66 
    77import xml.dom.minidom 
    8 from gip_common import fileRead 
     8from gip_common import fileRead, fileOverWrite 
    99from xml.sax import make_parser 
    1010from xml.sax.handler import feature_external_ges 
     
    2222        if node.nodeType == node.TEXT_NODE: 
    2323            rc = rc + node.data 
     24        if node.childNodes: 
     25            for child in node.childNodes: 
     26                if child.nodeType == node.CDATA_SECTION_NODE: 
     27                    rc = rc + child.data 
    2428    return rc 
    2529 
     
    5862    parser.parse(fp) 
    5963 
     64def addChild(dom, leaf, child_name, text=""): 
     65    child = dom.createElement(child_name) 
     66    leaf.appendChild(child) 
     67    text = str(text) 
     68    if len(text) > 0: 
     69        txtNode = dom.createTextNode(text) 
     70        child.appendChild(txtNode) 
     71     
     72    return child 
    6073 
     74def writeXML(dom, filename, pretty=False): 
     75    if pretty: 
     76        contents = dom.toprettyxml() 
     77    else: 
     78        contents = dom.toxml() 
     79    fileOverWrite(filename, contents)