Debian Codegraph @

lib/XML/LibXML/Node.pod

raw
1 =head1 NAME
2
3 XML::LibXML::Node - Abstract Base Class of XML::LibXML Nodes
4
5 =head1 SYNOPSIS
6
7
8
9 use XML::LibXML;
10
11 $name = $node->nodeName;
12 $node->setNodeName( $newName );
13 $bool = $node->isSameNode( $other_node );
14 $bool = $node->isEqual( $other_node );
15 $num = $node->unique_key;
16 $content = $node->nodeValue;
17 $content = $node->textContent;
18 $type = $node->nodeType;
19 $node->unbindNode();
20 $childnode = $node->removeChild( $childnode );
21 $oldnode = $node->replaceChild( $newNode, $oldNode );
22 $node->replaceNode($newNode);
23 $childnode = $node->appendChild( $childnode );
24 $childnode = $node->addChild( $childnode );
25 $node = $parent->addNewChild( $nsURI, $name );
26 $node->addSibling($newNode);
27 $newnode =$node->cloneNode( $deep );
28 $parentnode = $node->parentNode;
29 $nextnode = $node->nextSibling();
30 $nextnode = $node->nextNonBlankSibling();
31 $prevnode = $node->previousSibling();
32 $prevnode = $node->previousNonBlankSibling();
33 $boolean = $node->hasChildNodes();
34 $childnode = $node->firstChild;
35 $childnode = $node->lastChild;
36 $documentnode = $node->ownerDocument;
37 $node = $node->getOwner;
38 $node->setOwnerDocument( $doc );
39 $node->insertBefore( $newNode, $refNode );
40 $node->insertAfter( $newNode, $refNode );
41 @nodes = $node->findnodes( $xpath_expression );
42 $result = $node->find( $xpath );
43 print $node->findvalue( $xpath );
44 $bool = $node->exists( $xpath_expression );
45 @childnodes = $node->childNodes();
46 @childnodes = $node->nonBlankChildNodes();
47 $xmlstring = $node->toString($format,$docencoding);
48 $c14nstring = $node->toStringC14N();
49 $c14nstring = $node->toStringC14N($with_comments, $xpath_expression , $xpath_context);
50 $c14nstring = $node->toStringC14N_v1_1();
51 $c14nstring = $node->toStringC14N_v1_1($with_comments, $xpath_expression , $xpath_context);
52 $ec14nstring = $node->toStringEC14N();
53 $ec14nstring = $node->toStringEC14N($with_comments, $xpath_expression, $inclusive_prefix_list);
54 $ec14nstring = $node->toStringEC14N($with_comments, $xpath_expression, $xpath_context, $inclusive_prefix_list);
55 $str = $doc->serialize($format);
56 $localname = $node->localname;
57 $nameprefix = $node->prefix;
58 $uri = $node->namespaceURI();
59 $boolean = $node->hasAttributes();
60 @attributelist = $node->attributes();
61 $URI = $node->lookupNamespaceURI( $prefix );
62 $prefix = $node->lookupNamespacePrefix( $URI );
63 $node->normalize;
64 @nslist = $node->getNamespaces;
65 $node->removeChildNodes();
66 $strURI = $node->baseURI();
67 $node->setBaseURI($strURI);
68 $node->nodePath();
69 $lineno = $node->line_number();
70
71 =head1 DESCRIPTION
72
73 XML::LibXML::Node defines functions that are common to all Node Types. An
74 XML::LibXML::Node should never be created standalone, but as an instance of a
75 high level class such as XML::LibXML::Element or XML::LibXML::Text. The class
76 itself should provide only common functionality. In XML::LibXML each node is
77 part either of a document or a document-fragment. Because of this there is no
78 node without a parent. This may causes confusion with "unbound" nodes.
79
80
81 =head1 METHODS
82
83 Many functions listed here are extensively documented in the DOM Level 3 specification (L<<<<<< http://www.w3.org/TR/DOM-Level-3-Core/ >>>>>>). Please refer to the specification for extensive documentation.
84
85 =over 4
86
87 =item nodeName
88
89 $name = $node->nodeName;
90
91 Returns the node's name. This function is aware of namespaces and returns the
92 full name of the current node (C<<<<<< prefix:localname >>>>>>).
93
94 Since 1.62 this function also returns the correct DOM names for node types with
95 constant names, namely: #text, #cdata-section, #comment, #document,
96 #document-fragment.
97
98
99 =item setNodeName
100
101 $node->setNodeName( $newName );
102
103 In very limited situations, it is useful to change a nodes name. In the DOM
104 specification this should throw an error. This Function is aware of namespaces.
105
106
107 =item isSameNode
108
109 $bool = $node->isSameNode( $other_node );
110
111 returns TRUE (1) if the given nodes refer to the same node structure, otherwise
112 FALSE (0) is returned.
113
114
115 =item isEqual
116
117 $bool = $node->isEqual( $other_node );
118
119 deprecated version of isSameNode().
120
121 I<<<<<< NOTE >>>>>> isEqual will change behaviour to follow the DOM specification
122
123
124 =item unique_key
125
126 $num = $node->unique_key;
127
128 This function is not specified for any DOM level. It returns a key guaranteed
129 to be unique for this node, and to always be the same value for this node. In
130 other words, two node objects return the same key if and only if isSameNode
131 indicates that they are the same node.
132
133 The returned key value is useful as a key in hashes.
134
135
136 =item nodeValue
137
138 $content = $node->nodeValue;
139
140 If the node has any content (such as stored in a C<<<<<< text node >>>>>>) it can get requested through this function.
141
142 I<<<<<< NOTE: >>>>>> Element Nodes have no content per definition. To get the text value of an
143 Element use textContent() instead!
144
145
146 =item textContent
147
148 $content = $node->textContent;
149
150 this function returns the content of all text nodes in the descendants of the
151 given node as specified in DOM.
152
153
154 =item nodeType
155
156 $type = $node->nodeType;
157
158 Return a numeric value representing the node type of this node. The module
159 XML::LibXML by default exports constants for the node types (see the EXPORT
160 section in the L<<<<<< XML::LibXML >>>>>> manual page).
161
162
163 =item unbindNode
164
165 $node->unbindNode();
166
167 Unbinds the Node from its siblings and Parent, but not from the Document it
168 belongs to. If the node is not inserted into the DOM afterwards, it will be
169 lost after the program terminates. From a low level view, the unbound node is
170 stripped from the context it is and inserted into a (hidden) document-fragment.
171
172
173 =item removeChild
174
175 $childnode = $node->removeChild( $childnode );
176
177 This will unbind the Child Node from its parent C<<<<<< $node >>>>>>. The function returns the unbound node. If C<<<<<< oldNode >>>>>> is not a child of the given Node the function will fail.
178
179
180 =item replaceChild
181
182 $oldnode = $node->replaceChild( $newNode, $oldNode );
183
184 Replaces the C<<<<<< $oldNode >>>>>> with the C<<<<<< $newNode >>>>>>. The C<<<<<< $oldNode >>>>>> will be unbound from the Node. This function differs from the DOM L2
185 specification, in the case, if the new node is not part of the document, the
186 node will be imported first.
187
188
189 =item replaceNode
190
191 $node->replaceNode($newNode);
192
193 This function is very similar to replaceChild(), but it replaces the node
194 itself rather than a childnode. This is useful if a node found by any XPath
195 function, should be replaced.
196
197
198 =item appendChild
199
200 $childnode = $node->appendChild( $childnode );
201
202 The function will add the C<<<<<< $childnode >>>>>> to the end of C<<<<<< $node >>>>>>'s children. The function should fail, if the new childnode is already a child
203 of C<<<<<< $node >>>>>>. This function differs from the DOM L2 specification, in the case, if the new
204 node is not part of the document, the node will be imported first.
205
206
207 =item addChild
208
209 $childnode = $node->addChild( $childnode );
210
211 As an alternative to appendChild() one can use the addChild() function. This
212 function is a bit faster, because it avoids all DOM conformity checks.
213 Therefore this function is quite useful if one builds XML documents in memory
214 where the order and ownership (C<<<<<< ownerDocument >>>>>>) is assured.
215
216 addChild() uses libxml2's own xmlAddChild() function. Thus it has to be used
217 with extra care: If a text node is added to a node and the node itself or its
218 last childnode is as well a text node, the node to add will be merged with the
219 one already available. The current node will be removed from memory after this
220 action. Because perl is not aware of this action, the perl instance is still
221 available. XML::LibXML will catch the loss of a node and refuse to run any
222 function called on that node.
223
224
225
226 my $t1 = $doc->createTextNode( "foo" );
227 my $t2 = $doc->createTextNode( "bar" );
228 $t1->addChild( $t2 ); # is OK
229 my $val = $t2->nodeValue(); # will fail, script dies
230
231 Also addChild() will not check if the added node belongs to the same document
232 as the node it will be added to. This could lead to inconsistent documents and
233 in more worse cases even to memory violations, if one does not keep track of
234 this issue.
235
236 Although this sounds like a lot of trouble, addChild() is useful if a document
237 is built from a stream, such as happens sometimes in SAX handlers or filters.
238
239 If you are not sure about the source of your nodes, you better stay with
240 appendChild(), because this function is more user friendly in the sense of
241 being more error tolerant.
242
243
244 =item addNewChild
245
246 $node = $parent->addNewChild( $nsURI, $name );
247
248 Similar to C<<<<<< addChild() >>>>>>, this function uses low level libxml2 functionality to provide faster
249 interface for DOM building. I<<<<<< addNewChild() >>>>>> uses C<<<<<< xmlNewChild() >>>>>> to create a new node on a given parent element.
250
251 addNewChild() has two parameters $nsURI and $name, where $nsURI is an
252 (optional) namespace URI. $name is the fully qualified element name;
253 addNewChild() will determine the correct prefix if necessary.
254
255 The function returns the newly created node.
256
257 This function is very useful for DOM building, where a created node can be
258 directly associated with its parent. I<<<<<< NOTE >>>>>> this function is not part of the DOM specification and its use will limit your
259 code to XML::LibXML.
260
261
262 =item addSibling
263
264 $node->addSibling($newNode);
265
266 addSibling() allows adding an additional node to the end of a nodelist, defined
267 by the given node.
268
269
270 =item cloneNode
271
272 $newnode =$node->cloneNode( $deep );
273
274 I<<<<<< cloneNode >>>>>> creates a copy of C<<<<<< $node >>>>>>. When $deep is set to 1 (true) the function will copy all child nodes as well.
275 If $deep is 0 only the current node will be copied. Note that in case of
276 element, attributes are copied even if $deep is 0.
277
278 Note that the behavior of this function for $deep=0 has changed in 1.62 in
279 order to be consistent with the DOM spec (in older versions attributes and
280 namespace information was not copied for elements).
281
282
283 =item parentNode
284
285 $parentnode = $node->parentNode;
286
287 Returns simply the Parent Node of the current node.
288
289
290 =item nextSibling
291
292 $nextnode = $node->nextSibling();
293
294 Returns the next sibling if any .
295
296
297 =item nextNonBlankSibling
298
299 $nextnode = $node->nextNonBlankSibling();
300
301 Returns the next non-blank sibling if any (a node is blank if it is a Text or
302 CDATA node consisting of whitespace only). This method is not defined by DOM.
303
304
305 =item previousSibling
306
307 $prevnode = $node->previousSibling();
308
309 Analogous to I<<<<<< getNextSibling >>>>>> the function returns the previous sibling if any.
310
311
312 =item previousNonBlankSibling
313
314 $prevnode = $node->previousNonBlankSibling();
315
316 Returns the previous non-blank sibling if any (a node is blank if it is a Text
317 or CDATA node consisting of whitespace only). This method is not defined by
318 DOM.
319
320
321 =item hasChildNodes
322
323 $boolean = $node->hasChildNodes();
324
325 If the current node has child nodes this function returns TRUE (1), otherwise
326 it returns FALSE (0, not undef).
327
328
329 =item firstChild
330
331 $childnode = $node->firstChild;
332
333 If a node has child nodes this function will return the first node in the child
334 list.
335
336
337 =item lastChild
338
339 $childnode = $node->lastChild;
340
341 If the C<<<<<< $node >>>>>> has child nodes this function returns the last child node.
342
343
344 =item ownerDocument
345
346 $documentnode = $node->ownerDocument;
347
348 Through this function it is always possible to access the document the current
349 node is bound to.
350
351
352 =item getOwner
353
354 $node = $node->getOwner;
355
356 This function returns the node the current node is associated with. In most
357 cases this will be a document node or a document fragment node.
358
359
360 =item setOwnerDocument
361
362 $node->setOwnerDocument( $doc );
363
364 This function binds a node to another DOM. This method unbinds the node first,
365 if it is already bound to another document.
366
367 This function is the opposite calling of L<<<<<< XML::LibXML::Document >>>>>>'s adoptNode() function. Because of this it has the same limitations with
368 Entity References as adoptNode().
369
370
371 =item insertBefore
372
373 $node->insertBefore( $newNode, $refNode );
374
375 The method inserts C<<<<<< $newNode >>>>>> before C<<<<<< $refNode >>>>>>. If C<<<<<< $refNode >>>>>> is undefined, the newNode will be set as the new last child of the parent node.
376 This function differs from the DOM L2 specification, in the case, if the new
377 node is not part of the document, the node will be imported first,
378 automatically.
379
380 $refNode has to be passed to the function even if it is undefined:
381
382
383
384 $node->insertBefore( $newNode, undef ); # the same as $node->appendChild( $newNode );
385 $node->insertBefore( $newNode ); # wrong
386
387 Note, that the reference node has to be a direct child of the node the function
388 is called on. Also, $newChild is not allowed to be an ancestor of the new
389 parent node.
390
391
392 =item insertAfter
393
394 $node->insertAfter( $newNode, $refNode );
395
396 The method inserts C<<<<<< $newNode >>>>>> after C<<<<<< $refNode >>>>>>. If C<<<<<< $refNode >>>>>> is undefined, the newNode will be set as the new last child of the parent node.
397
398 Note, that $refNode has to be passed explicitly even if it is undef.
399
400
401 =item findnodes
402
403 @nodes = $node->findnodes( $xpath_expression );
404
405 I<<<<<< findnodes >>>>>> evaluates the xpath expression (XPath 1.0) on the current node and returns the
406 resulting node set as an array. In scalar context, returns an L<<<<<< XML::LibXML::NodeList >>>>>> object.
407
408 The xpath expression can be passed either as a string, or as a L<<<<<< XML::LibXML::XPathExpression >>>>>> object.
409
410 I<<<<<< NOTE ON NAMESPACES AND XPATH >>>>>>:
411
412 A common mistake about XPath is to assume that node tests consisting of an
413 element name with no prefix match elements in the default namespace. This
414 assumption is wrong - by XPath specification, such node tests can only match
415 elements that are in no (i.e. null) namespace.
416
417 So, for example, one cannot match the root element of an XHTML document with C<<<<<< $node-E<gt>find('/html') >>>>>> since C<<<<<< '/html' >>>>>> would only match if the root element C<<<<<< E<lt>htmlE<gt> >>>>>> had no namespace, but all XHTML elements belong to the namespace
418 http://www.w3.org/1999/xhtml. (Note that C<<<<<< xmlns="..." >>>>>> namespace declarations can also be specified in a DTD, which makes the
419 situation even worse, since the XML document looks as if there was no default
420 namespace).
421
422 There are several possible ways to deal with namespaces in XPath:
423
424
425 =over 4
426
427 =item *
428
429 The recommended way is to use the L<<<<<< XML::LibXML::XPathContext >>>>>> module to define an explicit context for XPath evaluation, in which a document
430 independent prefix-to-namespace mapping can be defined. For example:
431
432
433
434 my $xpc = XML::LibXML::XPathContext->new;
435 $xpc->registerNs('x', 'http://www.w3.org/1999/xhtml');
436 $xpc->find('/x:html',$node);
437
438
439
440 =item *
441
442 Another possibility is to use prefixes declared in the queried document (if
443 known). If the document declares a prefix for the namespace in question (and
444 the context node is in the scope of the declaration), C<<<<<< XML::LibXML >>>>>> allows you to use the prefix in the XPath expression, e.g.:
445
446
447
448 $node->find('/x:html');
449
450
451
452 =back
453
454 See also XML::LibXML::XPathContext->findnodes.
455
456
457 =item find
458
459 $result = $node->find( $xpath );
460
461 I<<<<<< find >>>>>> evaluates the XPath 1.0 expression using the current node as the context of the
462 expression, and returns the result depending on what type of result the XPath
463 expression had. For example, the XPath "1 * 3 + 52" results in a L<<<<<< XML::LibXML::Number >>>>>> object being returned. Other expressions might return an L<<<<<< XML::LibXML::Boolean >>>>>> object, or an L<<<<<< XML::LibXML::Literal >>>>>> object (a string). Each of those objects uses Perl's overload feature to "do
464 the right thing" in different contexts.
465
466 The xpath expression can be passed either as a string, or as a L<<<<<< XML::LibXML::XPathExpression >>>>>> object.
467
468 See also L<<<<<< XML::LibXML::XPathContext >>>>>>->find.
469
470
471 =item findvalue
472
473 print $node->findvalue( $xpath );
474
475 I<<<<<< findvalue >>>>>> is exactly equivalent to:
476
477
478
479 $node->find( $xpath )->to_literal;
480
481 That is, it returns the literal value of the results. This enables you to
482 ensure that you get a string back from your search, allowing certain shortcuts.
483 This could be used as the equivalent of XSLT's <xsl:value-of
484 select="some_xpath"/>.
485
486 See also L<<<<<< XML::LibXML::XPathContext >>>>>>->findvalue.
487
488 The xpath expression can be passed either as a string, or as a L<<<<<< XML::LibXML::XPathExpression >>>>>> object.
489
490
491 =item exists
492
493 $bool = $node->exists( $xpath_expression );
494
495 This method behaves like I<<<<<< findnodes >>>>>>, except that it only returns a boolean value (1 if the expression matches a
496 node, 0 otherwise) and may be faster than I<<<<<< findnodes >>>>>>, because the XPath evaluation may stop early on the first match (this is true
497 for libxml2 >= 2.6.27).
498
499 For XPath expressions that do not return node-set, the method returns true if
500 the returned value is a non-zero number or a non-empty string.
501
502
503 =item childNodes
504
505 @childnodes = $node->childNodes();
506
507 I<<<<<< childNodes >>>>>> implements a more intuitive interface to the childnodes of the current node. It
508 enables you to pass all children directly to a C<<<<<< map >>>>>> or C<<<<<< grep >>>>>>. If this function is called in scalar context, a L<<<<<< XML::LibXML::NodeList >>>>>> object will be returned.
509
510
511 =item nonBlankChildNodes
512
513 @childnodes = $node->nonBlankChildNodes();
514
515 This is like I<<<<<< childNodes >>>>>>, but returns only non-blank nodes (where a node is blank if it is a Text or
516 CDATA node consisting of whitespace only). This method is not defined by DOM.
517
518
519 =item toString
520
521 $xmlstring = $node->toString($format,$docencoding);
522
523 This method is similar to the method C<<<<<< toString >>>>>> of a L<<<<<< XML::LibXML::Document >>>>>> but for a single node. It returns a string consisting of XML serialization of
524 the given node and all its descendants. Unlike C<<<<<< XML::LibXML::Document::toString >>>>>>, in this case the resulting string is by default a character string (UTF-8
525 encoded with UTF8 flag on). An optional flag $format controls indentation, as
526 in C<<<<<< XML::LibXML::Document::toString >>>>>>. If the second optional $docencoding flag is true, the result will be a byte
527 string in the document encoding (see C<<<<<< XML::LibXML::Document::actualEncoding >>>>>>).
528
529
530 =item toStringC14N
531
532 $c14nstring = $node->toStringC14N();
533 $c14nstring = $node->toStringC14N($with_comments, $xpath_expression , $xpath_context);
534
535 The function is similar to toString(). Instead of simply serializing the
536 document tree, it transforms it as it is specified in the XML-C14N
537 Specification (see L<<<<<< http://www.w3.org/TR/xml-c14n >>>>>>). Such transformation is known as canonization.
538
539 If $with_comments is 0 or not defined, the result-document will not contain any
540 comments that exist in the original document. To include comments into the
541 canonized document, $with_comments has to be set to 1.
542
543 The parameter $xpath_expression defines the nodeset of nodes that should be
544 visible in the resulting document. This can be used to filter out some nodes.
545 One has to note, that only the nodes that are part of the nodeset, will be
546 included into the result-document. Their child-nodes will not exist in the
547 resulting document, unless they are part of the nodeset defined by the xpath
548 expression.
549
550 If $xpath_expression is omitted or empty, toStringC14N() will include all nodes
551 in the given sub-tree, using the following XPath expressions: with comments
552
553 (. | .//node() | .//@* | .//namespace::*)
554
555 and without comments
556
557 (. | .//node() | .//@* | .//namespace::*)[not(self::comment())]
558
559
560
561 An optional parameter $xpath_context can be used to pass an L<<<<<< XML::LibXML::XPathContext >>>>>> object defining the context for evaluation of $xpath_expression. This is useful
562 for mapping namespace prefixes used in the XPath expression to namespace URIs.
563 Note, however, that $node will be used as the context node for the evaluation,
564 not the context node of $xpath_context!
565
566
567 =item toStringC14N_v1_1
568
569 $c14nstring = $node->toStringC14N_v1_1();
570 $c14nstring = $node->toStringC14N_v1_1($with_comments, $xpath_expression , $xpath_context);
571
572 This function behaves like toStringC14N() except that it uses the
573 "XML_C14N_1_1" constant for canonicalising using the "C14N 1.1 spec".
574
575
576 =item toStringEC14N
577
578 $ec14nstring = $node->toStringEC14N();
579 $ec14nstring = $node->toStringEC14N($with_comments, $xpath_expression, $inclusive_prefix_list);
580 $ec14nstring = $node->toStringEC14N($with_comments, $xpath_expression, $xpath_context, $inclusive_prefix_list);
581
582 The function is similar to toStringC14N() but follows the XML-EXC-C14N
583 Specification (see L<<<<<< http://www.w3.org/TR/xml-exc-c14n >>>>>>) for exclusive canonization of XML.
584
585 The arguments $with_comments, $xpath_expression, $xpath_context are as in
586 toStringC14N(). An ARRAY reference can be passed as the last argument
587 $inclusive_prefix_list, listing namespace prefixes that are to be handled in
588 the manner described by the Canonical XML Recommendation (i.e. preserved in the
589 output even if the namespace is not used). C.f. the spec for details.
590
591
592 =item serialize
593
594 $str = $doc->serialize($format);
595
596 An alias for toString(). This function was name added to be more consistent
597 with libxml2.
598
599
600 =item serialize_c14n
601
602 An alias for toStringC14N().
603
604
605 =item serialize_exc_c14n
606
607 An alias for toStringEC14N().
608
609
610 =item localname
611
612 $localname = $node->localname;
613
614 Returns the local name of a tag. This is the part behind the colon.
615
616
617 =item prefix
618
619 $nameprefix = $node->prefix;
620
621 Returns the prefix of a tag. This is the part before the colon.
622
623
624 =item namespaceURI
625
626 $uri = $node->namespaceURI();
627
628 returns the URI of the current namespace.
629
630
631 =item hasAttributes
632
633 $boolean = $node->hasAttributes();
634
635 returns 1 (TRUE) if the current node has any attributes set, otherwise 0
636 (FALSE) is returned.
637
638
639 =item attributes
640
641 @attributelist = $node->attributes();
642
643 This function returns all attributes and namespace declarations assigned to the
644 given node.
645
646 Because XML::LibXML does not implement namespace declarations and attributes
647 the same way, it is required to test what kind of node is handled while
648 accessing the functions result.
649
650 If this function is called in array context the attribute nodes are returned as
651 an array. In scalar context, the function will return a L<<<<<< XML::LibXML::NamedNodeMap >>>>>> object.
652
653
654 =item lookupNamespaceURI
655
656 $URI = $node->lookupNamespaceURI( $prefix );
657
658 Find a namespace URI by its prefix starting at the current node.
659
660
661 =item lookupNamespacePrefix
662
663 $prefix = $node->lookupNamespacePrefix( $URI );
664
665 Find a namespace prefix by its URI starting at the current node.
666
667 I<<<<<< NOTE >>>>>> Only the namespace URIs are meant to be unique. The prefix is only document
668 related. Also the document might have more than a single prefix defined for a
669 namespace.
670
671
672 =item normalize
673
674 $node->normalize;
675
676 This function normalizes adjacent text nodes. This function is not as strict as
677 libxml2's xmlTextMerge() function, since it will not free a node that is still
678 referenced by the perl layer.
679
680
681 =item getNamespaces
682
683 @nslist = $node->getNamespaces;
684
685 If a node has any namespaces defined, this function will return these
686 namespaces. Note, that this will not return all namespaces that are in scope,
687 but only the ones declared explicitly for that node.
688
689 Although getNamespaces is available for all nodes, it only makes sense if used
690 with element nodes.
691
692
693 =item removeChildNodes
694
695 $node->removeChildNodes();
696
697 This function is not specified for any DOM level: It removes all childnodes
698 from a node in a single step. Other than the libxml2 function itself
699 (xmlFreeNodeList), this function will not immediately remove the nodes from the
700 memory. This saves one from getting memory violations, if there are nodes still
701 referred to from the Perl level.
702
703
704 =item baseURI ()
705
706 $strURI = $node->baseURI();
707
708 Searches for the base URL of the node. The method should work on both XML and
709 HTML documents even if base mechanisms for these are completely different. It
710 returns the base as defined in RFC 2396 sections "5.1.1. Base URI within
711 Document Content" and "5.1.2. Base URI from the Encapsulating Entity". However
712 it does not return the document base (5.1.3), use method C<<<<<< URI >>>>>> of C<<<<<< XML::LibXML::Document >>>>>> for this.
713
714
715 =item setBaseURI ($strURI)
716
717 $node->setBaseURI($strURI);
718
719 This method only does something useful for an element node in an XML document.
720 It sets the xml:base attribute on the node to $strURI, which effectively sets
721 the base URI of the node to the same value.
722
723 Note: For HTML documents this behaves as if the document was XML which may not
724 be desired, since it does not effectively set the base URI of the node. See RFC
725 2396 appendix D for an example of how base URI can be specified in HTML.
726
727
728 =item nodePath
729
730 $node->nodePath();
731
732 This function is not specified for any DOM level: It returns a canonical
733 structure based XPath for a given node.
734
735
736 =item line_number
737
738 $lineno = $node->line_number();
739
740 This function returns the line number where the tag was found during parsing.
741 If a node is added to the document the line number is 0. Problems may occur, if
742 a node from one document is passed to another one.
743
744 IMPORTANT: Due to limitations in the libxml2 library line numbers greater than
745 65535 will be returned as 65535. Please see L<<<<<< http://bugzilla.gnome.org/show_bug.cgi?id=325533 >>>>>> for more details.
746
747 Note: line_number() is special to XML::LibXML and not part of the DOM
748 specification.
749
750 If the line_numbers flag of the parser was not activated before parsing,
751 line_number() will always return 0.
752
753
754
755 =back
756
757 =head1 AUTHORS
758
759 Matt Sergeant,
760 Christian Glahn,
761 Petr Pajas
762
763
764 =head1 VERSION
765
766 2.0134
767
768 =head1 COPYRIGHT
769
770 2001-2007, AxKit.com Ltd.
771
772 2002-2006, Christian Glahn.
773
774 2006-2009, Petr Pajas.
775
776 =cut
777
778
779 =head1 LICENSE
780
781 This program is free software; you can redistribute it and/or modify it under
782 the same terms as Perl itself.
783