import xml.etree.ElementTree as ET
import pandas as pd
import wget

import urllib.request
# Downloading dataset
#urllib.request.urlretrieve("https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%205/data/Sample-employee-XML-file.xml", "new_sample.xml")
#urllib.request.urlretrieve("https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg", "dog.jpg")
wget.download("https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg")

# create the file structure
employee = ET.Element('employee')
details = ET.SubElement(employee, 'details')
first = ET.SubElement(details, 'firstname')
second = ET.SubElement(details, 'lastname')
third = ET.SubElement(details, 'age')
first.text = 'Shiv'
second.text = 'Mishra'
third.text = '23'

# create a new XML file with the results
mydata1 = ET.ElementTree(employee)
# myfile = open("items2.xml", "wb")
# myfile.write(mydata)
with open("new_sample.xml", "wb") as files:
    mydata1.write(files)

#wget.download("https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%205/data/Sample-employee-XML-file.xml")


root = tree.getroot()
columns = ["firstname", "lastname", "title", "division", "building","room"]

datatframe = pd.DataFrame(columns = columns)

for node in root: 
    print("i")
    firstname = node.find("firstname").text

    lastname = node.find("lastname").text 

    title = node.find("title").text 
    
    division = node.find("division").text 
    
    building = node.find("building").text
    
    room = node.find("room").text
    
    datatframe = datatframe.append(pd.Series([firstname, lastname, title, division, building, room], index = columns), ignore_index = True)

104913f96a427954ae8b9417b2f88b2267d62431
<mask token>

<mask token>
wget.download(
    'https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg'
    )
<mask token>
with open('new_sample.xml', 'wb') as files:
    mydata1.write(files)
<mask token>
for node in root:
    print('i')
    firstname = node.find('firstname').text
    lastname = node.find('lastname').text
    title = node.find('title').text
    division = node.find('division').text
    building = node.find('building').text
    room = node.find('room').text
    datatframe = datatframe.append(pd.Series([firstname, lastname, title,
        division, building, room], index=columns), ignore_index=True)

<mask token>
wget.download(
    'https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg'
    )
employee = ET.Element('employee')
details = ET.SubElement(employee, 'details')
first = ET.SubElement(details, 'firstname')
second = ET.SubElement(details, 'lastname')
third = ET.SubElement(details, 'age')
first.text = 'Shiv'
second.text = 'Mishra'
third.text = '23'
mydata1 = ET.ElementTree(employee)
with open('new_sample.xml', 'wb') as files:
    mydata1.write(files)
root = tree.getroot()
columns = ['firstname', 'lastname', 'title', 'division', 'building', 'room']
datatframe = pd.DataFrame(columns=columns)
for node in root:
    print('i')
    firstname = node.find('firstname').text
    lastname = node.find('lastname').text
    title = node.find('title').text
    division = node.find('division').text
    building = node.find('building').text
    room = node.find('room').text
    datatframe = datatframe.append(pd.Series([firstname, lastname, title,
        division, building, room], index=columns), ignore_index=True)

import xml.etree.ElementTree as ET
import pandas as pd
import wget
import urllib.request
wget.download(
    'https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg'
    )
employee = ET.Element('employee')
details = ET.SubElement(employee, 'details')
first = ET.SubElement(details, 'firstname')
second = ET.SubElement(details, 'lastname')
third = ET.SubElement(details, 'age')
first.text = 'Shiv'
second.text = 'Mishra'
third.text = '23'
mydata1 = ET.ElementTree(employee)
with open('new_sample.xml', 'wb') as files:
    mydata1.write(files)
root = tree.getroot()
columns = ['firstname', 'lastname', 'title', 'division', 'building', 'room']
datatframe = pd.DataFrame(columns=columns)
for node in root:
    print('i')
    firstname = node.find('firstname').text
    lastname = node.find('lastname').text
    title = node.find('title').text
    division = node.find('division').text
    building = node.find('building').text
    room = node.find('room').text
    datatframe = datatframe.append(pd.Series([firstname, lastname, title,
        division, building, room], index=columns), ignore_index=True)

import xml.etree.ElementTree as ET
import pandas as pd
import wget

import urllib.request
# Downloading dataset
#urllib.request.urlretrieve("https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%205/data/Sample-employee-XML-file.xml", "new_sample.xml")
#urllib.request.urlretrieve("https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg", "dog.jpg")
wget.download("https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg")

# create the file structure
employee = ET.Element('employee')
details = ET.SubElement(employee, 'details')
first = ET.SubElement(details, 'firstname')
second = ET.SubElement(details, 'lastname')
third = ET.SubElement(details, 'age')
first.text = 'Shiv'
second.text = 'Mishra'
third.text = '23'

# create a new XML file with the results
mydata1 = ET.ElementTree(employee)
# myfile = open("items2.xml", "wb")
# myfile.write(mydata)
with open("new_sample.xml", "wb") as files:
    mydata1.write(files)

#wget.download("https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-SkillsNetwork/labs/Module%205/data/Sample-employee-XML-file.xml")


root = tree.getroot()
columns = ["firstname", "lastname", "title", "division", "building","room"]

datatframe = pd.DataFrame(columns = columns)

for node in root: 
    print("i")
    firstname = node.find("firstname").text

    lastname = node.find("lastname").text 

    title = node.find("title").text 
    
    division = node.find("division").text 
    
    building = node.find("building").text
    
    room = node.find("room").text
    
    datatframe = datatframe.append(pd.Series([firstname, lastname, title, division, building, room], index = columns), ignore_index = True)
