<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18904"></HEAD>
<BODY>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010>Hi,</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN class=993485614-25042010>This is my 
first try at XML with Python, and though I tried to read on the web, I'm unable 
to traverse a DOM tree, as my top element seems to be DOCUMENT_NODE and I cannot 
find a way to get to the nodes below it.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN class=993485614-25042010>Below is a 
sample data, script and execution.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN class=993485614-25042010>Could you 
point to where I'm doing wrong ?</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010>Thanks,</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010>Ron.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial><SPAN 
class=993485614-25042010></SPAN></FONT> </DIV><FONT color=#0000ff 
face=Arial><SPAN class=993485614-25042010>
<DIV>
<HR>
</DIV>
<DIV> </DIV>
<DIV><FONT size=2 face="Courier New">$ <FONT color=#000000>python -u 
xml_parse.py<BR></FONT>node: <xml.dom.minidom.DocumentType instance at 
0x00DE25A8><BR>dom2.nodeType: 9<BR>dom2.nodeName: #document<BR>node is 
DOCUMENT_NODE: <xml.dom.minidom.DocumentType instance at 
0x00DE25A8><BR>node: <DOM Element: database at 
0xde2698><BR>dom2.nodeType: 9<BR>dom2.nodeName: #document<BR>node is 
DOCUMENT_NODE: <DOM Element: database at 
0xde2698><BR>('dom2._get_childNodes():', [<xml.dom.minidom.DocumentType 
instance at 0x00DE25A8>, <DOM Element: database at 
0xde2698>])<BR>Traceback (most recent call last):<BR>  File 
"xml_parse.py", line 26, in <module><BR>    
print("child_nodes._get_childNodes():",child_nodes._get_childNodes())<BR>AttributeError: 
'NodeList' object has no attribute '_get_childNodes'</FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">$ <FONT color=#000000>cat xml_parse.py 
<BR></FONT>#!/usr/bin/env python</FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">from xml.dom.minidom import parse, 
parseString</FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">xml_file_path ='example.xml'<BR>in_xml = 
open(xml_file_path)<BR>tmp = in_xml.read()<BR>doctype_loc = 
tmp.rfind("<!DOCTYPE")<BR>open_squere_par_loc = 
tmp.find("[",doctype_loc)<BR>first_part = tmp[:open_squere_par_loc + 
1]<BR>close_squere_par_loc = tmp.find("]>",doctype_loc)<BR>last_part = 
tmp[close_squere_par_loc:]<BR>xml_string = "%s%s" % (first_part, 
last_part)<BR>dom2 = parseString(xml_string)  </FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">for node in 
dom2.childNodes:<BR>    print "node:",node<BR>    
print "dom2.nodeType:",dom2.nodeType<BR>    print 
"dom2.nodeName:",dom2.nodeName<BR>    if dom2.nodeType == 
dom2.ELEMENT_NODE:<BR>        print "node is 
ELEMENT_NODE:",node<BR>    elif dom2.nodeType == 
dom2.DOCUMENT_NODE:<BR>        print "node is 
DOCUMENT_NODE:",node<BR>child_nodes = 
dom2._get_childNodes()<BR>print("dom2._get_childNodes():",dom2._get_childNodes())<BR>print("child_nodes._get_childNodes():",child_nodes._get_childNodes())<BR>dom2.unlink()</FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">$ <FONT color=#000000>cat example.xml 
<BR></FONT><?xml version="1.0" encoding="UTF-8"?><BR><!DOCTYPE database 
[<BR><!ELEMENT database (DbPortCharacteristic*, DbDpmPersonality*, 
DbHostMode*, DbGlobalSettings*, DbSimulatedDisk*, DbUserPermission*, DbUser*, 
DbUserSession*, DbUserGroup*, DbLicenseKey*, DbObjectBase*, 
DbFolderQueryMetadata*, DbFolder*, DbVDevAccessPermissions*, DbApplicationType*, 
DbPReserve*, DbVDevAgentBroadcastMsg*, DbVDev*, DbConsistencyGroup*, DbVolume*, 
DbPit*, DbView*, DbStripeSegment*, DbPool*, DbStripe*, DbScsiAddress*, DbDisk*, 
DbHbaAccessPath*, DbHba*, DbSubnodeGroupInfo*, DbSubnodeGroup*, DbHbaGroup*, 
DbPrRequest*, DbDomain*, DbSvmInfo*, DbPermTemplate*, DbPersonality*, 
DbMessageGroup*, DbJobBase*, DbMmJob*, DbMmRJob*, DbMcJob*, DbMcRJob*, 
DbGroupBase*, DbMmGroup*, DbMmRGroup*, DbMcGroup*, DbMcRGroup*, 
DbLoadBalanceNode*, DbBrokenMmJobInfo*, DbSmGroup*, DbSmJob*, DbDestVolInfo*, 
DbJobDestPermission*, DbVSSSnapshotSet*, DbVSSSnapshot*, 
DbPoolAlertData*)><BR><!ELEMENT DbPortCharacteristic (m_id, m_PortAddress, 
m_PortNumber, m_MtuActive, m_MtuSupported, m_SpeedCurrent, m_SpeedMax, 
m_ScsiRoleInfo, m_FCPortTypeInfo, m_InterfaceProtocolType, m_PortStatus, 
m_HbaGroup)><BR><!ELEMENT m_id 
(#PCDATA)><BR>]><BR><database><BR> <DbPortCharacteristic 
id="9429"><BR>  <m_id>2</m_id><BR>  
<m_PortAddress>"5001438102cfba20"</m_PortAddress><BR>  
<m_PortNumber>0</m_PortNumber><BR>  
<m_MtuActive>2048</m_MtuActive><BR>  
<m_MtuSupported>2048</m_MtuSupported><BR>  
<m_SpeedCurrent>0</m_SpeedCurrent><BR>  
<m_SpeedMax>4</m_SpeedMax><BR>  
<m_ScsiRoleInfo>1</m_ScsiRoleInfo><BR>  
<m_FCPortTypeInfo>1</m_FCPortTypeInfo><BR>  
<m_InterfaceProtocolType>3</m_InterfaceProtocolType><BR>  
<m_PortStatus>0</m_PortStatus><BR>  <m_HbaGroup><ref 
id="8967"/></m_HbaGroup><BR> </DbPortCharacteristic><BR></database></FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New"><FONT size=3 face=Arial><FONT size=2 
face="Courier New">$ <FONT color=#000000>python -V<BR></FONT>Python 
2.6.4</FONT><BR></FONT></DIV>
<DIV><BR></DIV>
<DIV>
<HR>
</DIV></FONT></SPAN></FONT></BODY></HTML>