Oct-31-2016, 05:19 PM
XML
can some one please guide me through this one . I am trying to make an xml from the data below .
Drug XML
Create an XML structure that describes a set of drugs and the possible dosages they might have based on the table below.
Create an element named <drug> for each drug entry.
Make the name, dosage, units, and cost attributes of each drug. Note that the cost is the cost per pill rather than the cost mg.
Make the count the text for that drug element.
Name Dosage Units Cost Count
Asprin 100 mg 0.10 320
Asprin 200 mg 0.15 211
Digoxin 10 mL 1.22 19
Digoxin 20 mL 2.01 27
Below is my code
drugs = """<?xml version="1.0"?>
<drugs>
<drug1 Name="Aspirin" Dosage ="100" Units="mg" Cost= "0.10">
Count = 320
</start>
<drug1 Name="Aspirin" Dosage ="200" Units="mg" Cost= "0.15">
Count =211
</start>
<drug1 Name="Digoxin" Dosage ="10" Units="mL" Cost= "1.22">
Count =19
</start>
<drug1 Name="Digoxin" Dosage ="20" Units="mL" Cost= "2.01">
Count =27
</start>
</drugs>
"""
Thanks
can some one please guide me through this one . I am trying to make an xml from the data below .
Drug XML
Create an XML structure that describes a set of drugs and the possible dosages they might have based on the table below.
Create an element named <drug> for each drug entry.
Make the name, dosage, units, and cost attributes of each drug. Note that the cost is the cost per pill rather than the cost mg.
Make the count the text for that drug element.
Name Dosage Units Cost Count
Asprin 100 mg 0.10 320
Asprin 200 mg 0.15 211
Digoxin 10 mL 1.22 19
Digoxin 20 mL 2.01 27
Below is my code
`import xml.etree.ElementTree as xmldrugs = """<?xml version="1.0"?>
<drugs>
<drug1 Name="Aspirin" Dosage ="100" Units="mg" Cost= "0.10">
Count = 320
</start>
<drug1 Name="Aspirin" Dosage ="200" Units="mg" Cost= "0.15">
Count =211
</start>
<drug1 Name="Digoxin" Dosage ="10" Units="mL" Cost= "1.22">
Count =19
</start>
<drug1 Name="Digoxin" Dosage ="20" Units="mL" Cost= "2.01">
Count =27
</start>
</drugs>
"""
` I am not very sure is it correct or not .Please guide me . Thanks