How to print the CDATA of .xml file?
Fredrik Lundh
fredrik at pythonware.com
Fri Oct 13 05:03:45 EDT 2006
Kevien Lee wrote:
> 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?
here's one way to do it, under Python 2.5:
import xml.etree.ElementTree as ET
tree = ET.parse(filename)
for elem in tree.findall(".//NodeArgs"):
print elem.findtext("Disp")
print elem.findtext("BtmPane/Path")
</F>
More information about the Python-list
mailing list