Pregunta

I need your help. I use lxml library to parsing dtd file.

How can i get c subexpression in this example?

dtd = etree.DTD(StringIO('<!ELEMENT a (b,c,d)>'))

I try this

content = dtd.elements()[0].content

left, right = content.left, content.right

but it left of right subexpression.

http://lxml.de/validation.html#id1

¿Fue útil?

Solución

I'm completely guessing (I've never touched this before) but:

from io import StringIO
from lxml import etree

dtd.elements()[0].content.right.left
#>>> <lxml.etree._DTDElementContentDecl object name='c' type='element' occur='once' at 0x7f6999a28250>

?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top