xpathns.py 548 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/python -u
  2. #
  3. import libxml2
  4. expect=' xmlns:a="urn:whatevar"'
  5. # Memory debug specific
  6. libxml2.debugMemory(1)
  7. d = libxml2.parseDoc("<a:a xmlns:a='urn:whatevar'/>")
  8. res=""
  9. for n in d.xpathEval("//namespace::*"):
  10. res = res + n.serialize()
  11. d.freeDoc()
  12. if res != expect:
  13. print "test5 failed: unexpected output"
  14. print res
  15. del res
  16. del d
  17. del n
  18. # Memory debug specific
  19. libxml2.cleanupParser()
  20. if libxml2.debugMemory(1) == 0:
  21. print "OK"
  22. else:
  23. print "Memory leak %d bytes" % (libxml2.debugMemory(1))
  24. libxml2.dumpMemory()