in XML:TWIG, how to stop parsing once find the interested element

后端 未结 1 807
野性不改
野性不改 2021-01-18 16:03

I only want to parse an interested element of xml (e.g. see below: class element with name equals to math) and I want to stop once the first element hitting this condition i

相关标签:
1条回答
  • 2021-01-18 17:01

    It seems what you're looking for are XML::Twig's finish_print and finish_now :

    finish_print

    Stops twig processing, flush the twig and proceed to finish printing the document as fast as possible. Use this method when modifying a document and the modification is done.

    finish_now

    Stops twig processing, does not finish parsing the document (which could actually be not well-formed after the point where finish_now is called). Execution resumes after the Lparse> or parsefile call. The content of the twig is what has been parsed so far (all open elements at the time finish_now is called are considered closed).

    0 讨论(0)
提交回复
热议问题