]> lifelog.hopto.org Git - PerlCNF.git/commitdiff
Further refined find all selector for nodes.
authorWill Budic <redacted>
Wed, 1 May 2024 09:04:45 +0000 (19:04 +1000)
committerWill Budic <redacted>
Wed, 1 May 2024 09:04:45 +0000 (19:04 +1000)
system/modules/CNFNode.pm
tests/testCNFNode.pl

index 66ae63b25dbc40a099232d570a66cdbea59d950f..e4c7614be224b36a2dc12a0dd3272b1b2a0c85cb 100644 (file)
@@ -147,7 +147,7 @@ sub items(){
 ###
 sub find {
     my ($self, $path, $ret, $prev, $seekArray,$ref)=@_;  my (@arr,$seekPName);
-    foreach my $name(split(/\//, $path)){
+    foreach my $name(split(/\//, $path)){  next if !$name;
         if($name eq '*'){
             #return  \@arr if @arr; # The path instructs to return an array, which is set but return is set to single only found element.
             # foreach my $itm(@arr){
index 9ee412628bdabfd78d2be701c9bc81ad8d356eb4..9448f75e22eacf802d57bddb50dbee684f7cd226 100644 (file)
@@ -157,6 +157,9 @@ use Syntax::Keyword::Try; try {
             >div>
          >div>
          <text<Shallow>text>
+
+         attribute = "attribute value"
+
         >parent>
     ));
 
@@ -183,6 +186,9 @@ use Syntax::Keyword::Try; try {
     $test -> subcase("Select all text nodes in parent.")->
              evaluate("\$find2[/parent/*/text]",3,scalar @$find2);
     $test -> evaluate("\$find2[/parent/*/text]",'Shallow', $find2->[2]->val());
+    $test -> subcase("Find and return value of attribute.");
+    my $find3 = $node->find('/parent/attribute');
+    $test -> evaluate("[/parent/attribute]",'attribute value', $find3);
 
     #
     $test -> nextCase();