PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/scripts/galaxy_messaging/server/xml_helper.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 28 lines | 22 code | 2 blank | 4 comment | 0 complexity | e8489d08507007e8bb03a677d0715dbc MD5 | raw file
 1#======= XML helper methods ====================================================
 2
 3import xml.dom.minidom
 4
 5def get_value( dom, tag_name ):
 6    '''
 7    This method extracts the tag value from the xml message
 8    '''
 9    nodelist = dom.getElementsByTagName( tag_name )[ 0 ].childNodes
10    rc = ""
11    for node in nodelist:
12        if node.nodeType == node.TEXT_NODE:
13            rc = rc + node.data
14    return rc
15
16def get_value_index( dom, tag_name, dataset_id ):
17    '''
18    This method extracts the tag value from the xml message
19    '''
20    try:
21        nodelist = dom.getElementsByTagName( tag_name )[ dataset_id ].childNodes
22    except:
23        return None
24    rc = ""
25    for node in nodelist:
26        if node.nodeType == node.TEXT_NODE:
27            rc = rc + node.data
28    return rc