Xml
<ib>8.4.27.5</ib>
python
from xml.dom import minidom
xmldoc = minidom.parse(' C:\TestProfile. xml')
xmldoc
ibNodeList = xmldoc.getEleme ntsByTagName("i b")
firstChild = xmldoc.firstChi ld
for node in xmldoc.getEleme ntsByTagName('i b'): # visit every node
<ib>
print node.toxml()
node.replaceChi ld("<ib>8.4.27. 5</ib>",node)
Error
Traceback (most recent call last):
File "C:\Python25\Li b\site-packages\python win\pywin\frame work
\scriptutils.py ", line 310, in RunScript
exec codeObject in __main__.__dict __
File "C:\Documen ts and Settings\vineyo \Desktop\parseX ml.py", line
17, in <module>
node.firstChild .replaceChild(" <ib>8.4.27.5</ib>",node.first Child)
File "C:\Python25\li b\xml\dom\minid om.py", line 899, in replaceChild
self.nodeName + " nodes do not have children")
HierarchyReques tErr: #text nodes do not have children
Question:
Is there an easy way to replace the node value of <ib>? Perhaps I am
trying to use the wrong python XML library? Any help would be greatly
appreciated.
<ib>8.4.27.5</ib>
python
from xml.dom import minidom
xmldoc = minidom.parse(' C:\TestProfile. xml')
xmldoc
ibNodeList = xmldoc.getEleme ntsByTagName("i b")
firstChild = xmldoc.firstChi ld
for node in xmldoc.getEleme ntsByTagName('i b'): # visit every node
<ib>
print node.toxml()
node.replaceChi ld("<ib>8.4.27. 5</ib>",node)
Error
Traceback (most recent call last):
File "C:\Python25\Li b\site-packages\python win\pywin\frame work
\scriptutils.py ", line 310, in RunScript
exec codeObject in __main__.__dict __
File "C:\Documen ts and Settings\vineyo \Desktop\parseX ml.py", line
17, in <module>
node.firstChild .replaceChild(" <ib>8.4.27.5</ib>",node.first Child)
File "C:\Python25\li b\xml\dom\minid om.py", line 899, in replaceChild
self.nodeName + " nodes do not have children")
HierarchyReques tErr: #text nodes do not have children
Question:
Is there an easy way to replace the node value of <ib>? Perhaps I am
trying to use the wrong python XML library? Any help would be greatly
appreciated.
Comment