连接xml元素.text在python中

2024-04-24 14:56:47 发布

您现在位置:Python中文网/ 问答频道 /正文

python中是否有用于连接的函数元素.text同样的元素.tag名字?你知道吗

示例:

 p>     
        some text
        <i>(</i>
        <i>something</i>
        <i>something</i>
        <i>)</i>
        some text
        <i>proň, zač</i>
        the end of paragraph
    </p>

我想要的是:

 p>     
        some text
        <i>(something something)</i>
        some text
        <i>proň, zač</i>
        the end of paragraph
    </p>

Tags: ofthe函数text元素示例tagsome
1条回答
网友
1楼 · 发布于 2024-04-24 14:56:47

Is there some function in python for joining element.text with same tags name?

不,你必须自己编码。原因是这个库处理的是xml,而不仅仅是xhtml。一般来说,<tag>a</tag><tag>b</tag><tag>ab</tag>的含义不同。事实上,即使在html中,合并相邻的<p><block>标记也会改变文本的含义。你知道吗

相关问题 更多 >