我如何创建这样的XML:
<urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>http://...</loc>
</url>
</urlset>
如何使用xml.etree添加xsi:schemaLocation?这是我的代码:
urlset = ET.Element("urlset")
for url in self.urls:
url = ET.SubElement(urlset, "url")
ET.SubElement(url, "loc").text = url.loc
self.tree = ET.ElementTree(urlset)
self.tree.write(path)
是否有一种简单的方法来添加这样的属性?