Closed Alex-Jordan closed 5 years ago
I like "lxml" but it does not seem to be part of standard Python. Sounds like ElementTree is not as powerful/complete.
While poking around, I found this, which sounded helpful for this particular problem, but I won't claim to have studied it very carefully for this particular case:
https://stackoverflow.com/questions/5373902/python-xml-query-get-parent
The python documentation makes me think that
if problem_root.find('statement') is None:
can become
if problem_root.find('.//statement') is None:
since //
from XPATH is supported and the example in the documentation says about //
:
Selects all subelements, on all levels beneath the current element. For example, .//egg selects all egg elements in the entire tree.
That sounds right.
On 6/28/19 6:30 AM, Mitchel T. Keller wrote:
The python documentation makes me think that
|if problem_root.find('statement') is None:|
can become
|if problem_root.find('.//statement') is None:|
since |//| from XPATH is supported and the example in the documentation says about |//|:
Selects all subelements, on all levels beneath the current element. For example, .//egg selects all egg elements in the entire tree.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rbeezer/mathbook/issues/1120?email_source=notifications&email_token=AAOLM4VOAEPTUWX5HVO2EALP4YG6ZA5CNFSM4H4CBF72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY2CP3A#issuecomment-506734572, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOLM4S7TFW2BANWWEFZVYLP4YG6ZANCNFSM4H4CBF7Q.
Fied at #1164
In #1069 we started looking for a statement tag in extracted WW. Because my knowledge of tools for analyzing XML in Python is weak, I just found a way to check if there was a
statement
child of the rootwebwork
and called it a day. But this neglected to account for when there is astage
, with thestatement
inside the stage, making thestatement
a grandchild of the root, not a child.So we need a better way.