my PYTHON xml parser fails if there is a comment at the beginning of the xml file, for example:
<?xml version="1.0" encoding="utf-8"?> <component name="abc"> <pp> .... </pp> </component>
Is it wrong to post such a comment?
EDIT:
itβs good that it does not throw an error, but the DOM module will fail and will not recognize the child nodes:
import xml.dom.minidom as dom sub_tree = dom.parse('xyz.xml') for component in sub_tree.firstChild.childNodes: print(component)
I can not connect child nodes; sub_tree.firstChild.childNodes returns an empty list, but if I delete these 2 comments, I can scroll through the list and read them as usual!
EDIT:
Guys, this simple example works and is enough to understand this. run your python shell and execute this little code above. As soon as it returns nothing and after deleting the comments the node message will appear!
source share