私はlxml(2.2.8)を使用して、いくつかのXML(具体的にはXGMML)を作成および書き出しています。それを読んでいるアプリは明らかにかなりうるさく、トップレベルの要素を見たいと思っています:
<graph label="Test" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xlink="h
ttp://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-
ns#" xmlns:cy="http://www.cytoscape.org" xmlns="http://www.cs.rpi.edu/XGMML" di
rected="1">
xmlns:
これらの属性をlxmlで設定するにはどうすればよいですか?明らかなことを試してみれば
root.attrib['xmlns:dc']='http://purl.org/dc/elements/1.1/'
root.attrib['xmlns:xlink']='http://www.w3.org/1999/xlink'
root.attrib['xmlns:rdf']='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
root.attrib['xmlns:cy']='http://www.cytoscape.org'
root.attrib['xmlns']='http://www.cs.rpi.edu/XGMML'
lxmlはValueError: Invalid attribute name u'xmlns:dc'
私は過去にXMLとlxmlを単純なものにかなりの量使用しましたが、これまでのところ、名前空間について何も知る必要がないように管理しました。