Skip to content

Commit

Permalink
present doctype modification in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scoder committed Feb 18, 2015
1 parent ab09902 commit e2426c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion doc/parsing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Doctype information
The use of the libxml2 parsers makes some additional information available at
the API level. Currently, ElementTree objects can access the DOCTYPE
information provided by a parsed document, as well as the XML version and the
original encoding:
original encoding. Since lxml 3.5, the doctype references are mutable.

.. sourcecode:: pycon

Expand All @@ -329,6 +329,12 @@ original encoding:
>>> print(docinfo.encoding)
ascii

>>> docinfo.system_url = None
>>> docinfo.public_id = None
>>> print(etree.tostring(tree))
<!DOCTYPE html>
<html><body/></html>


The target parser interface
===========================
Expand Down
7 changes: 6 additions & 1 deletion doc/tutorial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,11 @@ general document handling.
>>> print(tree.docinfo.doctype)
<!DOCTYPE root SYSTEM "test">

>>> tree.docinfo.public_id = '-//W3C//DTD XHTML 1.0 Transitional//EN'
>>> tree.docinfo.system_url = 'file://local.dtd'
>>> print(tree.docinfo.doctype)
<!DOCTYPE root PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "file://local.dtd">

An ``ElementTree`` is also what you get back when you call the
``parse()`` function to parse files or file-like objects (see the
parsing section below).
Expand All @@ -736,7 +741,7 @@ as a DOCTYPE and other DTD content in the document:
.. sourcecode:: pycon

>>> print(etree.tostring(tree)) # lxml 1.3.4 and later
<!DOCTYPE root SYSTEM "test" [
<!DOCTYPE root PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "file://local.dtd" [
<!ENTITY tasty "parsnips">
]>
<root>
Expand Down

0 comments on commit e2426c6

Please sign in to comment.