1. Shlomi Fish
  2. perl-XML-LibXML


ma...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed 57077c7

Added new files to MANIFEST
Updated Changes to 1.00
Fixed findvalue() to use find() instead of findnodes()
Documented find, findvalue and updated findnodes docs

  • Participants
  • Parent commits 60e23e3
  • Branches default

Comments (0)

Files changed (4)

File Changes

View file
  • Ignore whitespace
 Revision history for Perl extension XML::LibXSLT.
+    - Added SAX serialisation
+    - Added a SAX builder module
+    - Fixed findnodes in scalar context to return a NodeList object
+    - Added findvalue($xpath)
+    - Added find(), which returns different things depending on the XPath
+    - Added Boolean, Number and Literal data types
+    - Added support for $doc->URI getter/setter
     - New have_library implementation

File LibXML.pm

View file
  • Ignore whitespace
 sub XML::LibXML::Node::findvalue {
     my ($node, $xpath) = @_;
-    return $node->findnodes($xpath)->to_literal->value;
+    return $node->find($xpath)->to_literal->value;
 sub XML::LibXML::Node::find {


View file
  • Ignore whitespace

File example/libxml.xml

View file
  • Ignore whitespace
 <method name="findnodes" 
     synopsis="@nodes = $node->findnodes( $xpath_statement );">
 	<b>findnodes</b> performs the xpath statement on the current node and 
-	returns the result as an array. 
+	returns the result as an array. In scalar context returns a
+	<i>XML::LibXML::NodeList</i> object.
+<method name="find"
+    synopsis="$result = $node->find( $xpath );">
+        <b>find</b> performs the xpath expression using the current
+        node as the context of the expression, and returns the result
+        depending on what type of result the XPath expression had. For
+        example, the XPath "1 * 3 + 52" results in a
+        <i>XML::LibXML::Number</i> object being returned. Other
+        expressions might return a <i>XML::LibXML::Boolean</i> object,
+        or a <i>XML::LibXML::Literal</i> object (a string). Each of
+        those objects uses Perl's overload feature to "do the right thing"
+        in different contexts.
+<method name="findvalue"
+    synopsis="print $node->findvalue( $xpath );">
+        <b>findvalue</b> is exactly equivalent to:
+$node->find( $xpath )->to_literal;
+        That is, it returns the literal value of the results. This enables
+        you to ensure that you get a string back from your search, allowing
+        certain shortcuts. This could be used as the equivalent of
+        &lt;xsl:value-of select="some_xpath"/>.
 <method name="getChildnodes" synopsis="@children = $node->getChildnodes();">