如何使用python从一行xml解析文本
我有一行xml,希望将所有文本部分解析为一个文本列表如何使用python从一行xml解析文本,python,regex,xml,Python,Regex,Xml,我有一行xml,希望将所有文本部分解析为一个文本列表 text = '<string name="status">Finishing <xliff:g id="number">%d</xliff:g> percent.</string>' 我使用正则表达式来完成这个简单的任务 import re pattern = re.compile(r'>.+<') match = re.findall(pattern, text) match
text = '<string name="status">Finishing <xliff:g id="number">%d</xliff:g> percent.</string>'
我使用正则表达式来完成这个简单的任务
import re
pattern = re.compile(r'>.+<')
match = re.findall(pattern, text)
match = ['>Finishing <xliff:g id="number">%d</xliff:g> percent.<']
重新导入
pattern=re.compile(r'>.+Finishing%d%.将您的正则表达式更新到此值
pattern = re.compile(r'. *?>(.+?)<')
pattern=re.compile(r'.*?>(.+?)谢谢你的建议。我会调查BeautifulSoup
pattern = re.compile(r'. *?>(.+?)<')