Parsing XML Entity with python xml.sax

后端 未结 2 813
挽巷
挽巷 2021-01-16 09:54

Parsing XML with python using xml.sax, but my code fails to catch Entities. Why doesn\'t skippedEntity() or resolveEntity() report in the following:

import          


        
2条回答
  •  心在旅途
    2021-01-16 10:31

    I think resolveEntity and skippedEntity are only called for external DTDs. I got this to work by modifying the XML.

    XML = """
    
    Entity: ¬
    """
    

    The external.dtd contains two simple entity declarations.

    
    
    

    Also, I got rid of resolveEntity.

    This outputs -

    TestHandler.startElement(), test : step: bar foo ()
    TestHandler.skippedEntity: not
    

    Hope this helps.

提交回复
热议问题