M
Maksim Kasimov
Hi, i'm faced with such a problem when i use xml.dom.minidom:
to append all child nodes from "doc" in "_requ" to "doc" in "_resp", i do the following:
_requ = minidom.parseString("<resp><doc><one>One</one><two>Two</two></doc></resp>")
_resp = minidom.parseString("<resp><doc/></resp>")
iSourseTag = _requ.getElementsByTagName('doc')[0]
iTargetTag = _resp.getElementsByTagName('doc')[0]
# it prints me that there are two child nodes
for iChild in iSourseTag.childNodes:
print iChild.toxml()
# when i walk elements, only first iteration was made
# and iSourseTag.childNodes now have only one element instead of two
for iChild in iSourseTag.childNodes:
iTargetTag.appendChild(iChild)
# it prints me that there is only one child node
for iChild in iSourseTag.childNodes:
print iChild.toxml()
i'm not sure, whether i append child nodes in properly way, but IMHO it looks like a bug.
My question is how to avoid the "iSourseTag" changes while iterate its nodes?
And, of course, how to append all child nodes to "iTargetTag"?
Thank for any help.
to append all child nodes from "doc" in "_requ" to "doc" in "_resp", i do the following:
_requ = minidom.parseString("<resp><doc><one>One</one><two>Two</two></doc></resp>")
_resp = minidom.parseString("<resp><doc/></resp>")
iSourseTag = _requ.getElementsByTagName('doc')[0]
iTargetTag = _resp.getElementsByTagName('doc')[0]
# it prints me that there are two child nodes
for iChild in iSourseTag.childNodes:
print iChild.toxml()
# when i walk elements, only first iteration was made
# and iSourseTag.childNodes now have only one element instead of two
for iChild in iSourseTag.childNodes:
iTargetTag.appendChild(iChild)
# it prints me that there is only one child node
for iChild in iSourseTag.childNodes:
print iChild.toxml()
i'm not sure, whether i append child nodes in properly way, but IMHO it looks like a bug.
My question is how to avoid the "iSourseTag" changes while iterate its nodes?
And, of course, how to append all child nodes to "iTargetTag"?
Thank for any help.