[Python-checkins] python/dist/src/Doc/lib xmldomminidom.tex,1.5,1.5.8.1

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
2002年10月24日 12:36:43 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv13947
Modified Files:
 Tag: release22-maint
	xmldomminidom.tex 
Log Message:
Update an example to use the DOM implementation object. Explain that
the parse() and parseString() functions use a separate parser, not
actually implement a parser. (This is a common question.)
Index: xmldomminidom.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldomminidom.tex,v
retrieving revision 1.5
retrieving revision 1.5.8.1
diff -C2 -d -r1.5 -r1.5.8.1
*** xmldomminidom.tex	26 Oct 2001 20:09:49 -0000	1.5
--- xmldomminidom.tex	24 Oct 2002 19:36:41 -0000	1.5.8.1
***************
*** 28,32 ****
 \end{verbatim}
 
! The parse function can take either a filename or an open file object. 
 
 \begin{funcdesc}{parse}{filename_or_file{, parser}}
--- 28,33 ----
 \end{verbatim}
 
! The \function{parse()} function can take either a filename or an open
! file object.
 
 \begin{funcdesc}{parse}{filename_or_file{, parser}}
***************
*** 51,64 ****
 content of the document.
 
! You can also create a \class{Document} node merely by instantiating a 
! document object. Then you could add child nodes to it to populate
 the DOM:
 
 \begin{verbatim}
! from xml.dom.minidom import Document
 
! newdoc = Document()
! newel = newdoc.createElement("some_tag")
! newdoc.appendChild(newel)
 \end{verbatim}
 
--- 52,84 ----
 content of the document.
 
! What the \function{parse()} and \function{parseString()} functions do
! is connect an XML parser with a ``DOM builder'' that can accept parse
! events from any SAX parser and convert them into a DOM tree. The name
! of the functions are perhaps misleading, but are easy to grasp when
! learning the interfaces. The parsing of the document will be
! completed before these functions return; it's simply that these
! functions do not provide a parser implementation themselves.
! 
! You can also create a \class{Document} by calling a method on a ``DOM
! Implementation'' object. You can get this object either by calling
! the \function{getDOMImplementation()} function in the
! \refmodule{xml.dom} package or the \module{xml.dom.minidom} module.
! Using the implementation from the \module{xml.dom.minidom} module will
! always return a \class{Document} instance from the minidom
! implementation, while the version from \refmodule{xml.dom} may provide
! an alternate implementation (this is likely if you have the
! \ulink{PyXML package}{http://pyxml.sourceforge.net/} installed). Once
! you have a \class{Document}, you can add child nodes to it to populate
 the DOM:
 
 \begin{verbatim}
! from xml.dom.minidom import getDOMImplementation
 
! impl = getDOMImplementation()
! 
! newdoc = impl.createDocument(None, "some_tag", None)
! top_element = newdoc.documentElement
! text = newdoc.createTextNode('Some textual content.')
! top_element.appendChild(text)
 \end{verbatim}
 
***************
*** 101,105 ****
 
 
! \subsection{DOM objects \label{dom-objects}}
 
 The definition of the DOM API for Python is given as part of the
--- 121,125 ----
 
 
! \subsection{DOM Objects \label{dom-objects}}
 
 The definition of the DOM API for Python is given as part of the

AltStyle によって変換されたページ (->オリジナル) /