我想插入这个字符串:
No, on the 5<Font Script="super">th</Font>
作为XML中的文本节点xml.dom.minidomcreateTextNode(),但是,在我将writexml()写入一个文件后,会标记:
^{pr2}$转向:
No, on the 5<Font Script="super">th</Font>
我怎样才能避免这种情况?谢谢。在
我的代码的一部分:
impl = minidom.getDOMImplementation()
dom = impl.createDocument(None, None, None)
TextTextNode = dom.createTextNode(text.decode("utf-8"))
Text = dom.createElement("Text")
Text.appendChild(TextTextNode)
fileToWrite = codecs.open(output, 'w', encoding='utf-8')
dom.writexml(fileToWrite, indent=" ", addindent=" ", newl="\n", encoding='utf-8')
fileToWrite.close()
cinecanvase规范中有一个示例:
<Text HAlign=”left” HPosition=”10.2” VAlign=”bottom” VPosition=”10.0”> This <Font Script=”super”>word </Font>is superscript </Text >
我需要将<Font>..</Font>
插入另一个元素中。在
我不熟悉这种格式,但它看起来像一个XML节点。试试这个:
结果是:
^{pr2}$请注意,要在文件中编写树的内容(当调用writexml)时,需要使用XML的树根调用
writexml
方法(使用dom
调用该方法,而不是使用根节点)相关问题 更多 >
编程相关推荐