reader8.py 696 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/python -u
  2. #
  3. # this tests the entities substitutions with the XmlTextReader interface
  4. #
  5. import sys
  6. import StringIO
  7. import libxml2
  8. # Memory debug specific
  9. libxml2.debugMemory(1)
  10. #
  11. # Parse a document testing the Close() API
  12. #
  13. docstr="""<foo>
  14. <label>some text</label>
  15. <item>100</item>
  16. </foo>"""
  17. reader = libxml2.readerForDoc(docstr, "test1", None, 0)
  18. ret = reader.Read()
  19. ret = reader.Read()
  20. ret = reader.Close()
  21. if ret != 0:
  22. print "Error closing the document test1"
  23. sys.exit(1)
  24. del reader
  25. # Memory debug specific
  26. libxml2.cleanupParser()
  27. if libxml2.debugMemory(1) == 0:
  28. print "OK"
  29. else:
  30. print "Memory leak %d bytes" % (libxml2.debugMemory(1))
  31. libxml2.dumpMemory()