比方說,我有一個XML文件是這樣的:如何合併屬於一個xml文件的同一節點中的內容?
<recs>
<REC>
<SYS_TOPIC>topic1 topic1</SYS_TOPIC>
<SYS_AUTHORS>author1</SYS_AUTHORS>
<DOC_CONTENT>content1 content1 content1 content1 content1 content1 content1</DOC_CONTENT>
<DOC_WRITEDATE>2016-12-01 09:30:10</DOC_WRITEDATE>
</REC>
<REC>
<SYS_TOPIC>topic2 topic2</SYS_TOPIC>
<SYS_AUTHORS>author2</SYS_AUTHORS>
<DOC_CONTENT>content2 content2 content2 content2 content2 content2 content1</DOC_CONTENT>
<DOC_WRITEDATE>2016-12-01 09:30:10</DOC_WRITEDATE>
</REC>
</recs>
如果我想在<DOC_CONTENT>
一起在一個標籤合併所有的內容?我試過root.findall('DOC_CONTENT').text
但是它的調音臺'list' object has no attribute 'text'
你能給一個需要輸出的例子嗎? –
@nick_gabpe我想要這樣: ' content1 content1 content1 content1 content1 content1 content2 content2 content2 content2 content1 DOC_CONTENT>'只要把中的所有內容放在同一個標記中就好了! –
Jess