1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
discard """
output: '''
<xml>
<head>
<div>Some text</div>
<div>Some more text </div>
</head>
<body>
<div>Some text in body</div>
<div>Some more text in body </div>
</body>
</xml>
'''
"""
# Test xmltree add/insert/delete/replace operations
import xmlparser
import xmltree
var baseDocBody = """
<body>
<div>Some text in body</div>
<div>Some more text in body </div>
</body>
"""
var baseDocBodyTree = parseXml(baseDocBody)
let initialDocBase = """
<xml>
<head>
<div>Some text</div>
<div>Some more text </div>
</head>
<body>
<div>Some text in body before replace </div>
<div>Some more text in body before replace </div>
</body>
</xml>
"""
var initialDocBaseTree = parseXml(initialDocBase)
proc test_replace() =
var testDoc = initialDocBaseTree
testDoc.replace(1, @[baseDocBodyTree])
echo $testDoc
test_replace()
|