ttree_delete.nim 836 B

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