问题
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
回答1:
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>
?
来源:https://stackoverflow.com/questions/18930244/parsing-dtd-file-with-lxml-library-python