本文整理汇总了Python中elementtree.ElementTree.Element.attrib["xmlns"]方法的典型用法代码示例。如果您正苦于以下问题:Python Element.attrib["xmlns"]方法的具体用法?Python Element.attrib["xmlns"]怎么用?Python Element.attrib["xmlns"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.Element
的用法示例。
在下文中一共展示了Element.attrib["xmlns"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConvertToKML
# 需要导入模块: from elementtree.ElementTree import Element [as 别名]
# 或者: from elementtree.ElementTree.Element import attrib["xmlns"] [as 别名]
def ConvertToKML(report):
root = Element(KML("kml"))
root.attrib["xmlns"] = "http://earth.google.com/kml/2.2"
doc = SubElement(root, KML("Document"))
for entry in report:
placemark = SubElement(doc, KML("Placemark"))
SubElement(placemark, KML("name")).text = entry["Address"]
SubElement(placemark, KML("description")).text = BuildDescription(entry)
# SubElement(placemark, KML("description")).text = entry['Details']
SubElement(SubElement(placemark, KML("Point")), KML("coordinates")).text = Geocode(entry["Address"])
return ElementTree(root)
示例2: GetFeedElement
# 需要导入模块: from elementtree.ElementTree import Element [as 别名]
# 或者: from elementtree.ElementTree.Element import attrib["xmlns"] [as 别名]
def GetFeedElement(feed):
"""Create an atom:feed element for the provided feed.
The provided feed must be in the format described at http://feedparser.org.
"""
root = Element("feed")
root.attrib["xmlns"] = "http://www.w3.org/2005/Atom"
TextElement(root, "title", feed.feed.get("title_detail"))
if feed.feed.has_key("links"):
for link in feed.feed.links:
LinkElement(root, "link", link)
TextElement(root, "subtitle", feed.feed.get("subtitle_detail"))
TextElement(root, "rights", feed.feed.get("rights_detail"))
SubElement(root, "generator").text = "feedarchive"
SubElement(root, "updated").text = rfc3339(time.time())
SubElementIf(root, "id", feed.feed.get("id"))
if feed.feed.has_key("image"):
SubElement(root, "icon").text = feed.feed.image.href
if feed.feed.has_key("tags"):
for tag in feed.feed.tags:
te = SubElement(root, "category")
if tag.get("term"): te.attrib["term"] = tag.term
if tag.get("scheme"): te.attrib["scheme"] = tag.scheme
if tag.get("label"): te.attrib["label"] = tag.label
PersonElement(root, "author", feed.feed.get("author_detail"))
for entry in feed.entries:
ee = SubElement(root, "entry")
TextElement(ee, "title", entry.get("title_detail"))
if entry.has_key("links"):
for link in entry.links:
LinkElement(ee, "link", link)
TextElement(ee, "summary", entry.get("summary_detail"))
TextElement(ee, "content", entry.get("content_detail"))
DateTimeElement(ee, "published", entry, "published")
DateTimeElement(ee, "updated", entry, "updated")
SubElementIf(ee, "id", entry.get("id"))
PersonElement(ee, "author", entry.get("author_detail"))
PersonElement(ee, "publisher", entry.get("publisher_detail"))
if entry.has_key("contributors"):
for contributor in entry.contributors:
PersonElement(ee, "contributor", contributor)
CreateSourceElement(ee, entry.get("source"))
return root