[Lxml-checkins] r44767 - lxml/branch/html/doc

ianb at codespeak.net ianb at codespeak.net
Fri Jul 6 08:43:31 CEST 2007


Author: ianb
Date: Fri Jul  6 08:43:29 2007
New Revision: 44767

Modified:
   lxml/branch/html/doc/lxmlhtml.txt
Log:
some more docs

Modified: lxml/branch/html/doc/lxmlhtml.txt
==============================================================================
--- lxml/branch/html/doc/lxmlhtml.txt	(original)
+++ lxml/branch/html/doc/lxmlhtml.txt	Fri Jul  6 08:43:29 2007
@@ -23,6 +23,49 @@
 .. _ElementTree:  http://effbot.org/zone/element-index.htm
 
 
+Parsing HTML
+============
+
+Parsing HTML fragments
+----------------------
+
+HTML Element Methods
+====================
+
+HTML elements have all the methods that come with ElementTree, but
+also include some extra methods:
+
+``.drop_tree()``:
+    Drops the element and all its children.  Unlike
+    ``el.getparent().remove(el)`` this does *not* remove the tail
+    text; with ``drop_tree`` the tail text is merged with the previous
+    element.
+
+``.drop_tag()``:
+    Drops the tag, but keeps its children and text.
+
+``.find_class(class_name)``:
+    Returns a list of all the elements with the given CSS class name.
+    Note that class names are space separated in HTML, so
+    ``doc.find_class_name('highlight')`` will find an element like
+    ``<div class="sidebar highlight">``.  Class names *are* case
+    sensitive.
+
+``.find_rel_links(rel)``:
+    Returns a list of all the ``<a rel="{rel}">`` elements.  E.g.,
+    ``doc.find_rel_links('tag')`` returns all the links `marked as
+    tags <http://microformats.org/wiki/rel-tag>`_.
+
+``.get_element_by_id(id, default=None)``:
+    Return the element with the given ``id``, or the ``default`` if
+    none is found.  If there are multiple elements with the same id
+    (which there shouldn't be, but there often is), this returns only
+    the first.
+
+``.text_content()``:
+    Returns the text content of the element, including the text
+    content of its children, with no markup.
+
 Running HTML doctests
 =====================
 
@@ -76,14 +119,6 @@
 namespaces and some other XMLisms.
 
 
-Parsing HTML
-============
-
-
-Parsing HTML fragments
-----------------------
-
-
 Creating HTML with the E-factory
 ================================
 


More information about the lxml-checkins mailing list