Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 创造!实体定义_Python_Xml_Lxml - Fatal编程技术网

Python 创造!实体定义

Python 创造!实体定义,python,xml,lxml,Python,Xml,Lxml,使用PythonLXML如何创建一个!实体定义,注意我想创建而不是解析 也就是说,我想创建一些包含另一个文件的xml,因此需要一个!实体定义您应该能够使用包含实体声明的内部子集创建doctype声明,作为字符串,并在序列化时传递该声明(使用tostring()或write() 例如 从lxml导入etree doctype=“” doc=etree.Element(“doc”) ent=电子交易实体(“ent”) 追加文件(ent) 打印(etree.tostring(doc,doctype=d

使用PythonLXML如何创建一个!实体定义,注意我想创建而不是解析


也就是说,我想创建一些包含另一个文件的xml,因此需要一个!实体定义

您应该能够使用包含实体声明的内部子集创建doctype声明,作为字符串,并在序列化时传递该声明(使用tostring()或write()

例如

从lxml导入etree
doctype=“”
doc=etree.Element(“doc”)
ent=电子交易实体(“ent”)
追加文件(ent)
打印(etree.tostring(doc,doctype=doctype.decode())
印刷品


&耳鼻喉科;

您应该能够创建doctype声明,其中包含实体声明的内部子集作为字符串,并在序列化时传递该声明(使用tostring()或write()

例如

从lxml导入etree
doctype=“”
doc=etree.Element(“doc”)
ent=电子交易实体(“ent”)
追加文件(ent)
打印(etree.tostring(doc,doctype=doctype.decode())
印刷品


&耳鼻喉科;

如何指定∧在子元素中?i、 e.我希望在哪里使用include@KeithSloan-你没有;使用
etree.entity(“ent”)
&
创建实体引用在序列化时自动添加。您如何/在何处添加创建的实体可能有所不同,但您尚未在问题中添加任何代码,因此我很难准确理解您的问题。您如何指定∧在子元素中?i、 e.我希望在哪里使用include@KeithSloan-你没有;使用
etree.entity(“ent”)
&
创建实体引用在序列化时自动添加。如何/在何处添加创建的实体可能有所不同,但您尚未在问题中添加任何代码,因此我很难准确理解您的问题。