(load "lib/tree/xml.egi") (define $xml1 <Node "top" {<Node "middle1" {<Leaf "bottom1" "text1"> <Leaf "bottom1" "text2"> <Leaf "bottom1" "text3"> <Node "bottom1" {<Leaf "bottom2" "text21"> <Leaf "bottom2" "text100"> <Leaf "bottom2" "text22">}> }> <Node "middle2" {<Leaf "bottom3" "text31"> <Leaf "bottom3" "text32"> <Leaf "bottom3" "text33"> <Leaf "bottom3" "text31"> <Leaf "bottom3" "text35"> }> <Node "middle3" {<Leaf "bottom4" "text41"> <Leaf "bottom4" "text42"> <Node "bottom4" {<Leaf "bottom2" "text51"> <Leaf "bottom2" "text100"> <Leaf "bottom2" "text53">}> <Leaf "bottom4" "text44"> <Leaf "bottom4" "text53"> }> }>) ;; List up all tags. (test (match-all xml1 xml [<descendant <mnode $tag _> _> [tag]])) ; {top middle1 middle2 middle3 bottom1 bottom4} ;; List up all nodes which has more than two same child nodes. (test (match-all xml1 xml [<descendant <mnode $tag <cons $x <cons ,x _>>>> [tag x]])) ; {[middle2 <Leaf bottom3 text31>] [middle2 <Leaf bottom3 text31>]} ;; List up all nodes which has more than two same descendant nodes. (test (match-all xml1 xml [<descendant <mnode $tag <cons <descendant $x> <cons <descendant ,x> _>>>> [tag x]])) ; {[middle2 <Leaf bottom3 text31>] [middle2 <Leaf bottom3 text31>] [top <Leaf bottom2 text100>] [top <Leaf bottom2 text100>]}