Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 08-26-2009;08-27-2009;08-29-2009
- for element in iter:
- # Look for a tag called "Timeinfo"
- if element.tag == "timeinfo":
- tree = root.find(".//timeinfo")
- # Clear all tags below "timeinfo"
- tree.clear()
- element.append(ET.Element("mdattim"))
- child1 = ET.SubElement(tree, "sngdate")
- child2 = ET.SubElement(child1, "caldate1")
- child3 = ET.SubElement(child1, "caldate2")
- child4 = ET.SubElement(child1, "caldate3")
- child2.text = FIRST DATE VARIABLE GOES HERE
- child2.text = SECOND DATE VARIABLE GOES HERE
- child2.text = THIRD DATE VARIABLE GOES HERE
- >>> a="08-26-2009;08-27-2009;08-29-2009"
- >>> a_split = a.split(';')
- >>> a_split
- ['08-26-2009', '08-27-2009', '08-29-2009']
- child2.text, child3.text, child4.text = three_dates_text.split(';')
- children = [ET.SubElement(tree, "sngdate")]
- children += [ET.SubElement(children[0], "caldate%s" % i) for i in xrange(3)]
- dates = "08-26-2009;08-27-2009;08-29-2009"
- for i, d in enumerate(dates.split(";")):
- children[i+1].date = d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement