This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: dom.Node.nodeValue not populated
Type: Stage:
Components: XML Versions: Python 2.3
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: raide
Priority: normal Keywords:

Created on 2004-01-29 03:30 by raide, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg19846 - (view) Author: Raide (raide) Date: 2004-01-29 03:30
I get the following behaviour:

>>> xmlStr = "<foo id='10'>test</foo>"
>>> from xml.dom.ext.reader import Sax2
>>> import xml.dom
>>> reader = Sax2.Reader()
>>> dom = reader.fromString(xmlStr)
>>> dom.getElementsByTagName('foo')[0].getAttribute('id')
u'10'
>>> dom.getElementsByTagName('foo')[0].nodeValue
>>>

which seems to be a bug. Perhaps my understanding of
the nodeValue attribute is wrong. Im running 2.3.3 on
Fedora Core 1
msg19847 - (view) Author: Raide (raide) Date: 2004-01-29 03:36
Logged In: YES 
user_id=122250

er... sorry, this form stripped the tags from xmlStr, it was:

>>> xmlStr = "<foo id='10'>test</foo>"

if the form strips html special chars then:

>>> xmlStr = "(foo id='10')test(/foo)" #replace ( and ) with
angle brackets
msg19848 - (view) Author: Raide (raide) Date: 2004-01-29 03:53
Logged In: YES 
user_id=122250

My apologies, Im an idiot who cannot read documentation
properly. 
The answer is:

dom.getElementsByTagName('foo')[0].childNodes[0].nodeValue

because CDATA has its own node.

Sorry for wasting anyones time.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39878
2004-01-29 03:30:51raidecreate