我想在XML文件中搜索xlink:href属性在所有标签中。我不能用beauthulsoup find\u all和正则表达式完成它。以下是我的XML文件。在
<body:document-content>
<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
<style:text-properties officeooo:paragraph-rsid="00118689"/>
</style:style>
<body:text>
<text:sequence-decls>
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
</text:sequence-decls>
<text:p text:style-name="P1">This is example document</text:p>
<text:p text:style-name="P1"/>
<text:p text:style-name="P1">hello world</text:p>
<text:p text:style-name="P1"/>
<text:p text:style-name="P1">
<text:a xlink:type="simple" xlink:href="https://example.com">https://example.com</text:a>
</text:p>
<text:p text:style-name="P1"/>
<text:p text:style-name="P1"/>
</body:text>
</body:document-content>
我想从XML文件中删除以下标记行。在
^{pr2}$请建议如何使用beautifulsoup完成此操作。我也试过Elementtree。但是,它带来了很多名称空间问题。在
这是一个过于简单的答案,但不清楚您要做什么,或者您的XML可能面临哪些变化。如果您不需要将XPath用于更复杂的操作,那么示例中的XML建议您只需搜索}属性的元素),如果它确实是您希望除去的
text:a
元素(唯一具有{text:a
“line”(元素节点)。在相关问题 更多 >
编程相关推荐