How to print the CDATA of .xml file?

Kevien Lee ironpythonster at gmail.com
Fri Oct 13 02:42:06 EDT 2006


Hi,
  Recently ,I just turn to Python from C#.However ,as a dynamic  language .
Python and C# was so different.

 Now ,I want to get some record from an XML file,The format of the XML file
as follow:
...............................
<Doc rID="T1"  >
    <DName><![CDATA[Release Truck]]></DName>
    <Res><![CDATA[Res18]]></Res>

   <DT rID="T2">
      <NodeArgs eType="Table" icon="2" nRep="5" filter="False" >
        <Disp><![CDATA[Run-Time Data]]></Disp>
        <BtmPane vType="Table">
          <Path><![CDATA[Default.xls]]></Path>
        </BtmPane>
      </NodeArgs>
    </DT>

    <NodeArgs eType="StartTest" icon="1" nRep="4" status="Failed" >
      <Disp><![CDATA[Test Release Truck Summary]]></Disp>
    </NodeArgs>

</Doc>
....................................

when i use the minidom to parase the XML file,it would ignored the section
of <![CDATA[.......]>
the code is:

_document=minidom.parse("filePath")
_documnetList=_document.getElementsByTagName("NodeArgs")
for _argNode in _documnetList:
    print _argNode.nodeValue,_argNode.localName

when it run. The nodeValue of the CDATA Section  is  always None,Is my code
error?
and how should i do when i want to get the value of the in the CDATA
section?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061013/0a3397f2/attachment.html>


More information about the Python-list mailing list