initial creation
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# from xml.etree import ElementTree as ET
|
||||
import lxml.etree as ET
|
||||
|
||||
movie_data = [
|
||||
('Jaws', 'Spielberg, Stephen'),
|
||||
('Vertigo', 'Alfred Hitchcock'),
|
||||
('Blazing Saddles', 'Brooks, Mel'),
|
||||
('Princess Bride', 'Reiner, Rob'),
|
||||
('Avatar', 'Cameron, James'),
|
||||
]
|
||||
|
||||
movies = ET.Element('movies')
|
||||
|
||||
for name, director in movie_data:
|
||||
movie = ET.SubElement(movies, 'movie', name=name)
|
||||
ET.SubElement(movie, 'director').text = director
|
||||
|
||||
print(ET.tostring(movies, pretty_print=True).decode())
|
||||
|
||||
doc = ET.ElementTree(movies)
|
||||
|
||||
doc.write('movies.xml')
|
||||
Reference in New Issue
Block a user