From 7b2f4e87e8c4a6f1110a6e251f306b4c91eed5f5 Mon Sep 17 00:00:00 2001 From: Will Budic Date: Wed, 1 May 2024 19:04:45 +1000 Subject: [PATCH] Further refined find all selector for nodes. --- system/modules/CNFNode.pm | 2 +- tests/testCNFNode.pl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/system/modules/CNFNode.pm b/system/modules/CNFNode.pm index 66ae63b..e4c7614 100644 --- a/system/modules/CNFNode.pm +++ b/system/modules/CNFNode.pm @@ -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){ diff --git a/tests/testCNFNode.pl b/tests/testCNFNode.pl index 9ee4126..9448f75 100644 --- a/tests/testCNFNode.pl +++ b/tests/testCNFNode.pl @@ -157,6 +157,9 @@ use Syntax::Keyword::Try; try { >div> >div> 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(); -- 2.34.1