5
# Memory debug specific
8
doc = libxml2.newDoc("1.0")
9
comment = doc.newDocComment("This is a generated document")
11
pi = libxml2.newPI("test", "PI content")
13
root = doc.newChild(None, "doc", None)
14
ns = root.newNs("http://example.com/doc", "my")
16
elem = root.newChild(None, "foo", "bar")
17
elem.setBase("http://example.com/imgs")
18
elem.setProp("img", "image.gif")
19
doc.saveFile("tmp.xml")
22
doc = libxml2.parseFile("tmp.xml")
23
comment = doc.children
24
if comment.type != "comment" or \
25
comment.content != "This is a generated document":
26
print "error rereading comment"
29
if pi.type != "pi" or pi.name != "test" or pi.content != "PI content":
30
print "error rereading PI"
33
if root.name != "doc":
34
print "error rereading root"
37
if ns.name != "my" or ns.content != "http://example.com/doc":
38
print "error rereading namespace"
41
if elem.name != "foo":
42
print "error rereading elem"
44
if elem.getBase(None) != "http://example.com/imgs":
45
print "error rereading base"
47
if elem.prop("img") != "image.gif":
48
print "error rereading property"
53
# Memory debug specific
54
libxml2.cleanupParser()
55
if libxml2.debugMemory(1) == 0:
58
print "Memory leak %d bytes" % (libxml2.debugMemory(1))