текст который нужно распарсить:
from pyparsing import *
texta = '''<RDF:RDF xmlns:NS1="http://amb.vis.ne.jp/mozilla/scrapbook-rdf#"
xmlns:NC="http://home.netscape.com/NC-rdf#"
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<RDF:Description RDF:about="urn:scrapbook:item20200711150730"
NS1:id="20200711150730"
NS1:create="20200711150730"
NS1:title="Делаем из Vim-а конфетку / Хабр"
NS1:chars="UTF-8"
NS1:source="https://habr.com/ru/post/468265/"
NS1:comment=""
NS1:lock=""
NS1:type=""
NS1:icon="resource://scrapbook/data/20200711150730/favicon-16x16.png"
NS1:modify="20200711150804" />
<RDF:Seq RDF:about="urn:scrapbook:item20200704081851">
<RDF:li RDF:resource="urn:scrapbook:item20200704081900"/>
<RDF:li RDF:resource="urn:scrapbook:item20200711150730"/>
</RDF:Seq>'''
код парсера:
ns_id_p = Literal("NS1:id=")
pars = ns_id_p + Suppress('"') + Word(nums) + Suppress('"')
xx = pars.searchString(texta)
xxx = xx[0]
yyy = xxx[1]
print('xx ', xx)
print('xxx ', xxx)
print('yyy ', yyy)
вывод:
xx [['NS1:id=', '20200711150730']]
xxx ['NS1:id=', '20200711150730']
yyy 20200711150730
как получить значение yyy более лаконично в стиле python