Commits

Gael Pasgrimaud committed d1110d4 Merge

merge

  • Participants
  • Parent commits 6462148, cb13868

Comments (0)

Files changed (1)

pyquery/__init__.py

 # Copyright (C) 2008 - Olivier Lauzanne <olauzanne@gmail.com>
 #
 # Distributed under the BSD license, see LICENSE.txt
-
 from types import DictionaryType
 
 from lxml.cssselect import css_to_xpath
             if children:
                 tag.extend(children)
             tag.text = root.text
+            tag.tail = root.tail
         return self
 
     def text(self, value=None):
             tag.text = value
         return self
 
+    ################
+    # Manipulating #
+    ################
+
+    def append(self, value):
+        root = etree.fromstring('<root>' + value + '</root>')
+        children = root.getchildren()
+        for tag in self:
+            tag.text += root.text
+            tag.extend(children)
+            if tag.tail and root.tail:
+                tag.tail += root.tail
+            elif root.tail:
+                tag.tail = root.tail
+        return self
+
 
 def test():
     import doctest