[issue38742] ElementTree won't parse comments before root element

2019-11-15 Thread Stefan Behnel


Stefan Behnel  added the comment:

Duplicate of issue 9521 (and issue 24287).

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> xml.etree.ElementTree skips processing instructions when parsing

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38742] ElementTree won't parse comments before root element

2019-11-08 Thread yucheng chen


New submission from yucheng chen :

issue8277
It couldn't work for those comments before the root element. 
It will raise an error that "xml.etree.ElementTree.ParseError: multiple 
elements on top level". 

Example:

test.xml




  
  
  


test.py
---
from xml.etree import ElementTree
class MyTreeBuilder(ElementTree.TreeBuilder):
   def comment(self, data):
   self.start(ElementTree.Comment, {})
   self.data(data)
   self.end(ElementTree.Comment)
with open('c:/temp/t.xml', 'r') as f:
   xml = ElementTree.parse(
   f, parser=ElementTree.XMLParser(target=MyTreeBuilder()))
ElementTree.dump(xml)

--
components: XML
messages: 356229
nosy: amaury.forgeotdarc, effbot, flox, poke, scoder, yucheng chen
priority: normal
severity: normal
status: open
title: ElementTree won't parse comments before root element
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com