paulb@40 | 1 | #!/usr/bin/env python |
paulb@40 | 2 | |
paulb@40 | 3 | import libxml2dom |
paulb@40 | 4 | import sys |
paulb@40 | 5 | |
paul@354 | 6 | test = """<?xml version="1.0"?> |
paul@354 | 7 | <test> |
paul@354 | 8 | <element attr="value">text</element> |
paul@354 | 9 | </test> |
paul@354 | 10 | """ |
paul@354 | 11 | |
paul@354 | 12 | d = libxml2dom.parseString(test) |
paul@354 | 13 | root = d.documentElement |
paulb@40 | 14 | d2 = libxml2dom.createDocument(None, "new", None) |
paul@354 | 15 | root2 = d2.documentElement |
paulb@40 | 16 | for i in range(0, 10): |
paulb@40 | 17 | imported = d2.importNode(root, 1) |
paulb@40 | 18 | root2.appendChild(imported) |
paul@354 | 19 | d2.toStream(sys.stdout, prettyprint=1) |
paulb@40 | 20 | |
paulb@40 | 21 | # vim: tabstop=4 expandtab shiftwidth=4 |