~ubuntu-branches/ubuntu/wily/bandit/wily-proposed

« back to all changes in this revision

Viewing changes to examples/xml_etree_elementtree.py

  • Committer: Package Import Robot
  • Author(s): Dave Walker (Daviey)
  • Date: 2015-07-22 09:01:39 UTC
  • Revision ID: package-import@ubuntu.com-20150722090139-fl0nluy0x8m9ctx4
Tags: upstream-0.12.0
ImportĀ upstreamĀ versionĀ 0.12.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import xml.etree.ElementTree as badET
 
2
import defusedxml.ElementTree as goodET
 
3
 
 
4
xmlString = "<note>\n<to>Tove</to>\n<from>Jani</from>\n<heading>Reminder</heading>\n<body>Don't forget me this weekend!</body>\n</note>"
 
5
 
 
6
# unsafe
 
7
tree = badET.fromstring(xmlString)
 
8
print(tree)
 
9
badET.parse('filethatdoesntexist.xml')
 
10
badET.iterparse('filethatdoesntexist.xml')
 
11
a = badET.XMLParser()
 
12
 
 
13
# safe
 
14
tree = goodET.fromstring(xmlString)
 
15
print(tree)
 
16
goodET.parse('filethatdoesntexist.xml')
 
17
goodET.iterparse('filethatdoesntexist.xml')
 
18
a = goodET.XMLParser()