---------- Forwarded message ----------
From: "Fredrik Lundh" <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Fri, 13 Oct 2006 11:03:45 +0200
Subject: Re: How to print the CDATA of .xml file?
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>
------------------------------------------------
From: "Fredrik Lundh" <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Fri, 13 Oct 2006 11:03:45 +0200
Subject: Re: How to print the CDATA of .xml file?
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>
------------------------------------------------
use Python 2.5 is easy and good, but is there any others way under version 2.4?
-- http://mail.python.org/mailman/listinfo/python-list