Class: Rexle::Element

Inherits:
Object
  • Object
show all
Includes:
XMLhelper
Defined in:
lib/rexle.rb

Defined Under Namespace

Classes: Attribute, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XMLhelper

#doc_pretty_print, #doc_print, #pretty_print, #processing_instructions, #scan_print, #scan_to_a

Constructor Details

#initialize(name = nil, value: nil, attributes: Attributes.new, rexle: self) ⇒ Element

Returns a new instance of Element.



322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/rexle.rb', line 322

def initialize(name=nil, value: nil, attributes: Attributes.new, rexle: self)

  @rexle = rexle
  super()

  @name, @attributes = name.to_s, attributes

  raise "Element name must not be blank" unless name
  @child_elements = []
  self.add_text value if value

end

Instance Attribute Details

#child_elementsObject (readonly)

Returns the value of attribute child_elements.



318
319
320
# File 'lib/rexle.rb', line 318

def child_elements
  @child_elements
end

#doc_idObject (readonly)

Returns the value of attribute doc_id.



318
319
320
# File 'lib/rexle.rb', line 318

def doc_id
  @doc_id
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



318
319
320
# File 'lib/rexle.rb', line 318

def instructions
  @instructions
end

#nameObject

Returns the value of attribute name.



317
318
319
# File 'lib/rexle.rb', line 317

def name
  @name
end

#parentObject

Returns the value of attribute parent.



317
318
319
# File 'lib/rexle.rb', line 317

def parent
  @parent
end

#valueObject

Returns the value of attribute value.



317
318
319
# File 'lib/rexle.rb', line 317

def value
  @value
end

Instance Method Details

#add(item) ⇒ Object



879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# File 'lib/rexle.rb', line 879

def add(item)

  if item.is_a? Rexle::Element then

    if self.doc_id == item.doc_id then

      new_item = item.deep_clone
      add_element new_item
      item.delete
      item = nil
      item = new_item
      new_item
    else
      add_element item
    end
  else
    add_element item
  end

end

#add_attribute(*x) ⇒ Object



908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
# File 'lib/rexle.rb', line 908

def add_attribute(*x)

  proc_hash = lambda {|x| Hash[*x]}

  procs = {
    Hash: lambda {|x| x[0] || {}},
    String: proc_hash,
    Symbol: proc_hash,
    :'Attributes::Value' => proc_hash
  }

  type = x[0].class.to_s.to_sym

  h = procs[type].call(x)

  @attributes.merge! h
end

#add_element(item) ⇒ Object



857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
# File 'lib/rexle.rb', line 857

def add_element(item)

  if item.is_a? String then
    @child_elements << Value.new(item)

  elsif item.is_a? Rexle::CData then
    @child_elements << item
  elsif item.is_a? Rexle::Comment then
    @child_elements << item
  elsif item.is_a? Rexle::Element then

    @child_elements << item
    # add a reference from this element (the parent) to the child
    item.parent = self
    item

  elsif item.is_a? Rexle then
    self.add_element(item.root)
  end

end

#add_text(s) ⇒ Object



926
927
928
929
930
# File 'lib/rexle.rb', line 926

def add_text(s)

  self.child_elements << s
  self
end

#at_css(selector) ⇒ Object



367
368
369
# File 'lib/rexle.rb', line 367

def at_css(selector)
  self.root.element RexleCSS.new(selector).to_xpath
end

#attribute(key) ⇒ Object



932
933
934
935
936
937
938
939
940
941
# File 'lib/rexle.rb', line 932

def attribute(key)

  key = key.to_sym if key.is_a? String

  if @attributes[key].is_a? String then
    @attributes[key].gsub('&lt;','<').gsub('&gt;','>')
  else
    @attributes[key]
  end
end

#attributesObject



943
# File 'lib/rexle.rb', line 943

def attributes() @attributes end

#backtrack(use_attributes: true) ⇒ Object



335
336
337
# File 'lib/rexle.rb', line 335

def backtrack(use_attributes: true)
  BacktrackXPath.new(self, use_attributes: use_attributes)
end

#cdata?Boolean

Returns:

  • (Boolean)


339
340
341
# File 'lib/rexle.rb', line 339

def cdata?()
  self.is_a? CData
end

#cdatasObject



945
946
947
# File 'lib/rexle.rb', line 945

def cdatas()
  self.children.inject([]){|r,x| x.is_a?(Rexle::CData) ? r << x.to_s : r }
end

#childrenObject



949
950
951
952
953
954
955
956
957
958
# File 'lib/rexle.rb', line 949

def children()

  r =  @child_elements

  def r.is_an_empty_string?()
    self.length == 1 and self.first == ''
  end

  return r
end

#children=(a) ⇒ Object



960
# File 'lib/rexle.rb', line 960

def children=(a)   @child_elements = a if a.is_a? Array  end

#cloneObject



964
965
966
# File 'lib/rexle.rb', line 964

def clone()
  Element.new(@name, attributes: Marshal.load( Marshal.dump(@attributes)))
end

#contains(raw_args) ⇒ Object



343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/rexle.rb', line 343

def contains(raw_args)

  path, raw_val = raw_args.split(',',2)
  val = raw_val.strip[/^["']?.*["']?$/]

  anode = query_xpath(path)

  return [false] if anode.nil? or anode.empty?

  a = scan_contents(anode.first)
  r = [a.grep(/#{val.sub(/^["'](.*)["']$/,'\1')}/).length > 0]

  r.any?
end

#content(options = {}) ⇒ Object



1104
1105
1106
# File 'lib/rexle.rb', line 1104

def content(options={})
  CGI.unescapeHTML(xml(options))
end

#count(path) ⇒ Object



358
359
360
361
# File 'lib/rexle.rb', line 358

def count(path)
  length = query_xpath(path).flatten.compact.length
  length
end

#css(selector) ⇒ Object



371
372
373
374
375
# File 'lib/rexle.rb', line 371

def css(selector)

  selector.split(',')\
              .flat_map{|x| self.root.xpath RexleCSS.new(x).to_xpath}
end

#currentObject



363
364
365
# File 'lib/rexle.rb', line 363

def current()
  self
end

#deep_cloneObject



962
# File 'lib/rexle.rb', line 962

def deep_clone() Rexle.new(self.xml).root end

#delete(obj = nil) ⇒ Object Also known as: remove



968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
# File 'lib/rexle.rb', line 968

def delete(obj=nil)

  if obj then

    if obj.is_a? String then

      self.xpath(obj).each {|e| e.delete; e = nil}

    else

      i = @child_elements.index(obj)
      [@child_elements].each{|x| x.delete_at i} if i
    end
  else

    self.parent.delete(self) if self.parent
  end
end

#doc_rootObject



1004
# File 'lib/rexle.rb', line 1004

def doc_root() @rexle.root                                  end

#each(&blk) ⇒ Object



1005
# File 'lib/rexle.rb', line 1005

def each(&blk)    self.children.each(&blk)                  end

#each_recursive(&blk) ⇒ Object Also known as: traverse



1006
# File 'lib/rexle.rb', line 1006

def each_recursive(&blk) recursive_scan(self.children,&blk) end

#element(s) ⇒ Object



989
990
991
992
# File 'lib/rexle.rb', line 989

def element(s)
  r = self.xpath(s)
  r.is_a?(Array) ? r.first : r
end

#elements(s = nil) ⇒ Object



994
995
996
997
998
999
1000
1001
1002
# File 'lib/rexle.rb', line 994

def elements(s=nil)
  procs = {
    NilClass: proc {Elements.new(@child_elements\
                                 .select{|x| x.kind_of? Rexle::Element })},
    String: proc {|x| @child_elements[x]}
  }

  procs[s.class.to_s.to_sym].call(s)
end

#filter_xpath(raw_path, rlist = [], &blk) ⇒ Object



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/rexle.rb', line 451

def filter_xpath(raw_path, rlist=[], &blk)
  #@log.debug 'inside filter_xpath : ' + raw_path.inspect
  path = String.new raw_path

  # is it a function
  fn_match = path.match(/^(\w+)\(["']?([^\)]*)["']?\)(?:\[(.*)\])?$/)
  #fn_match = path.match(/^(\w+)\(/)
  #@log.debug 'fn_match : ' + fn_match.inspect
  end_fn_match = path.slice!(/\[\w+\(\)\]$/)

  if end_fn_match then

    m = end_fn_match[1..-4]
    #@log.debug 'its a function'
    [method(m.to_sym).call(xpath path)]

  elsif (fn_match and fn_match.captures.first[/^(attribute|@)/])

    procs = {

      Array: proc { |x|
        if block_given? then
          x.flatten(1)
        else
          rs = x.flatten
          rs.any?{|x| x == true or x == false} ? rs : rs.uniq(&:object_id)
        end
      },
     String: proc {|x| x},
      Hash: proc {|x| x},
      TrueClass: proc{|x| x},
      FalseClass: proc{|x| x},
      :"Rexle::Element" => proc {|x| [x]}
    }
    bucket = []
    raw_results = path.split('|').map do |xp|
      query_xpath(xp.strip, bucket, &blk)
    end

    results = raw_results

    procs[results.class.to_s.to_sym].call(results) if results

  elsif fn_match.nil?

    procs = {

      Array: proc { |x|
        if block_given? then
          x.flatten(1)
        else
          rs = x.flatten
          rs.any?{|x| x == true or x == false} ? rs : rs.uniq(&:object_id)
        end
      },
     String: proc {|x| x},
      Hash: proc {|x| x},
      TrueClass: proc{|x| x},
      FalseClass: proc{|x| x},
      :"Rexle::Element" => proc {|x| [x]}
    }
    bucket = []

    results = if path =~ /[\[]|\(/ then

      raw_results = path.split(/\|/).map do |xp|
        query_xpath(xp.strip, bucket, &blk)
      end

      raw_results.flatten.index(true) ? [true] : []

    else
      raw_results = path.split(/ *(?:\||\band\b) */).map do |xp|
        query_xpath(xp.strip, bucket, &blk)
      end

      if path =~ / and / then

        raw_results.flatten.select {|x| x == true or x == false}

      else
        raw_results.flatten.index(true) ? [true] : []
      end
    end

    return results if !path[/[><]/] and results.any?
    results = raw_results # .flatten.select {|x| x}

    procs[results.class.to_s.to_sym].call(results) if results

  else

    m, xpath_value, index = fn_match.captures

    if m == 'text' then
      a = texts()
      return index ? a[index.to_i - 1].to_s : a
    end
    #@log.debug 'before function call'
    raw_results = xpath_value.empty? ? method(m.to_sym).call \
                                : method(m.to_sym).call(xpath_value)

    raw_results

  end

end

#has_elements?Boolean

Returns:

  • (Boolean)


1008
# File 'lib/rexle.rb', line 1008

def has_elements?() !self.elements.empty?                   end

#insert_after(node) ⇒ Object



1009
# File 'lib/rexle.rb', line 1009

def insert_after(node)   insert(node, 1)                    end

#insert_before(node) ⇒ Object



1010
# File 'lib/rexle.rb', line 1010

def insert_before(node)  insert(node)                       end

#inspectObject



900
901
902
903
904
905
906
# File 'lib/rexle.rb', line 900

def inspect()
  if self.xml.length > 30 then
  "%s ... </>" % self.xml[/<[^>]+>/]
  else
    self.xml
  end
end

#last(a) ⇒ Object



1011
# File 'lib/rexle.rb', line 1011

def last(a) a.last                                          end

#lowercase(s) ⇒ Object

not yet implemented



378
379
380
# File 'lib/rexle.rb', line 378

def lowercase(s)

end

#map(&blk) ⇒ Object



1012
# File 'lib/rexle.rb', line 1012

def map(&blk)    self.children.map(&blk)                    end

#max(path) ⇒ Object



382
383
384
385
# File 'lib/rexle.rb', line 382

def max(path)
  a = query_xpath(path).flatten.select{|x| x.is_a? String or x.is_a? Rexle::Element::Attribute}.map(&:to_i)
  a.max
end

#next_elementObject Also known as: next_sibling



403
404
405
406
407
408
409
410
411
# File 'lib/rexle.rb', line 403

def next_element()

  id  = self.object_id
  a = self.parent.elements

  i = a.index {|x| x.object_id == id} + 2
  a[i] if  i < a.length + 1

end

#not(bool) ⇒ Object



415
416
417
418
419
420
# File 'lib/rexle.rb', line 415

def not(bool)

  r = self.xpath(bool).any?

  !r
end

#original_cloneObject



320
# File 'lib/rexle.rb', line 320

alias original_clone clone

#plaintextObject



1014
1015
1016
1017
# File 'lib/rexle.rb', line 1014

def plaintext()
  CGI.unescapeHTML xml().gsub(/<\/?[^>]+>/,'').gsub('&nbsp;',' ')\
      .gsub(/\n\s+/,' ')
end

#prepend(item) ⇒ Object



1108
1109
1110
1111
1112
1113
1114
1115
# File 'lib/rexle.rb', line 1108

def prepend(item)

  @child_elements.unshift item

  # add a reference from this element (the parent) to the child
  item.parent = self
  item
end

#previous_elementObject Also known as: previous_sibling



422
423
424
425
426
427
428
429
430
# File 'lib/rexle.rb', line 422

def previous_element()

  id  = self.object_id
  a = self.parent.elements
  i = a.index {|x| x.object_id == id}

  a[i] if  i > 0

end

#query_xpath(raw_xpath_value, rlist = [], &blk) ⇒ Object



559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
# File 'lib/rexle.rb', line 559

def query_xpath(raw_xpath_value, rlist=[], &blk)

  #@log.debug 'query_xpath : ' + raw_xpath_value.inspect
  #@log.debug '++ ' + self.xml.inspect

  flag_func = false

  xpath_value = raw_xpath_value.sub('child::','./')

  if xpath_value[/^[\w\/]+\s*=.*/] then

    flag_func = true

    xpath_value.sub!(/^\w+\s*=.*/,'.[\0]')
    xpath_value.sub!(/\/([\w]+\s*=.*)/,'[\1]')

  end

  raw_path, raw_condition = xpath_value.sub(/^\.?\/(?!\/)/,'')\
      .match(/([^\[]+)(\[[^\]]+\])?/).captures

  remaining_path = ($').to_s

  #@log.debug 'remaining_path: ' + remaining_path.inspect

  if remaining_path[/^contains\(/] then

    raw_condition = raw_condition ? raw_condition + '/' + remaining_path \
                                                           : remaining_path
    remaining_path = ''
  end

  r = raw_path[/^([^\/]+)(?=\/\/)/,1]

  if r then
    a_path = raw_path.split(/(?=\/\/)/,2)
  else
    a_path = raw_path.split('/',2)
  end

  condition = raw_condition if a_path.length <= 1 #and not raw_condition[/^\[\w+\(.*\)\]$/]

  if raw_path[0,2] == '//' then
    s = ''
  elsif raw_path == 'text()'

    a_path.shift
    #return @value
    return self.texts
  else

    attribute = xpath_value[/^(attribute::|@)(.*)/,2]

    return @attributes  if attribute == '*'

    if attribute and @attributes and \
          @attributes.has_key?(attribute.to_sym) then
      return [Attribute.new(@attributes[attribute.to_sym])]
    end
    s = a_path.shift
  end

  # isolate the xpath to return just the path to the current element

  elmnt_path = s[/^([a-zA-Z:\-\*]+\[[^\]]+\])|[\/]+{,2}[^\/]+/]
  element_part = elmnt_path[/(^@?[^\[]+)?/,1] if elmnt_path

  if element_part then

    unless element_part[/^(@|[@\.a-zA-Z]+[\s=])/] then

      element_name = element_part[/^[\w:\-\*\.]+/]

      if element_name and element_name[/^\d/] then
        element_name = nil
      end

      condition = raw_xpath_value if element_name.nil?

    else

      if xpath_value[/^\[/] then
        condition = xpath_value
        element_name = nil
      else
        condition = element_part
        attr_search = format_condition('[' + condition + ']')

        #@log.debug 'attr_search : ' + attr_search.inspect
        return [attribute_search(attr_search, \
                                 self, self.attributes) != nil]
      end

    end

  end

  #element_name ||= '*'
  raw_condition = '' if condition

  attr_search = format_condition(condition) if condition \
                                            and condition.length > 0

  puts ('1. attr_search: ' + attr_search.inspect).debug if $debug
  #@log.debug 'attr_search2 : ' + attr_search.inspect
  attr_search2 = xpath_value[/^\[(.*)\]$/,1]

  if attr_search2 then
    #@log.debug 'before attribute_Search'
    r4 = attribute_search(attr_search, self, self.attributes)
    return r4
  end


  return_elements = []



  if raw_path[0,2] == '//' then

    regex = /\[(\d+)\]$/
    n = xpath_value[regex,1]
    xpath_value.slice!(regex)

    rs = scan_match(self, xpath_value).flatten.compact
    return n ? rs[n.to_i-1] : rs

  else

    if element_name.is_a? String then
      ename, raw_selector = (element_name.split('::',2)).reverse

      selector = case raw_selector
        when 'following-sibling' then 1
        when 'preceding-sibling' then -1
      end

    else
      ename = element_name
    end

    if ename == '..' then

      remaining_xpath = raw_path[/\.\.\/(.*)/,1]
      # select the parent element

      r2 =  self.parent.xpath(remaining_xpath)

      return r2

    elsif ename == '.'

      remaining_xpath = raw_path[1..-1]

      if remaining_xpath.empty? then
        if xpath_value.length > 0 and xpath_value =~ /\[/ then

            r = eval(attr_search.sub(/^h/,'self.attributes'))
            return self if r

        else
          return self
        end
      else
        return self.xpath(remaining_xpath)
      end

    elsif element_name.nil?
      puts ('attr_search: ' + attr_search.inspect).debug if $debug
      return eval attr_search
    else

      if raw_selector.nil? and ename != element_part  then

        right_cond = element_part[/#{ename}(.*)/,1]

      end

      return_elements = @child_elements.map.with_index.select do |x, i|

        next unless x.is_a? Rexle::Element

        #x.name == ename or  (ename == '*')

        r10 = ((x.name == ename) or  (ename == '*'))



      end

      if right_cond then


        r12 = return_elements.map do |x, i|

          if x.text then

            r11 = eval "'%s'%s" % [x.text.to_s, right_cond]

          else
            false
          end

        end

        return r12

      end

      if selector then
        ne = return_elements.inject([]) do |r,x|
          i = x.last + selector
          if i >= 0 then
            r << i
          else
            r
          end
        end

        return_elements = ne.map {|x| [@child_elements[x], x] if x}
      end


    end
  end

  if return_elements.length > 0 then

    if (a_path + [remaining_path]).join.empty? then

      # pass in a block to the filter if it is function contains?
      rlist = return_elements.map.with_index do |x,i|
        r5 = filter(x, i+1, attr_search, &blk)

        r5
      end.compact

      rlist = rlist[0] if rlist.length == 1

    else

      rlist << return_elements.map.with_index do |x,i|

        rtn_element = filter(x, i+1, attr_search) do |e|

          r = e.xpath(a_path.join('/') + raw_condition.to_s \
                + remaining_path, &blk)

          r = e if r.is_a?(Array) and r.first and r.first == true \
                                                          and a_path.empty?

          r
        end

        next if rtn_element.nil? or (rtn_element.is_a? Array \
                                                  and rtn_element.empty?)

        if rtn_element.is_a? Hash then
          rtn_element
        elsif rtn_element.is_a? Array then
          rtn_element
        elsif (rtn_element.is_a? String) || (rtn_element.is_a?(Array) \
                                      and not(rtn_element[0].is_a? String))
          rtn_element
        elsif rtn_element.is_a? Rexle::Element
          rtn_element
        elsif rtn_element  == true
          true
        end
      end

      rlist = rlist.flatten(1) unless rlist.length > 1 \
                                                   and rlist[0].is_a? Array
      rlist

    end

    rlist.compact! if rlist.is_a? Array

  else

    # strip off the 1st element from the XPath
    new_xpath = xpath_value[/^\/\/[\w:\-]+\/(.*)/,1]

    if new_xpath then
      self.xpath(new_xpath + raw_condition.to_s + remaining_path, \
                                                            rlist,&blk)
    end
  end

  rlist = rlist.flatten(1) unless not(rlist.is_a? Array) \
                             or (rlist.length > 1 and rlist[0].is_a? Array)
  rlist = [rlist] if rlist.is_a? Rexle::Element
  rlist = (rlist.length > 0 ? true : false) if flag_func == true

  rlist
end

#rootObject



1019
# File 'lib/rexle.rb', line 1019

def root() self                                             end

#text(s = '') ⇒ Object



1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'lib/rexle.rb', line 1021

def text(s='')

  return self.value if s.empty?

  e = self.element(s)
  return e if e.is_a? String

  e.value if e
end

#textsObject



1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
# File 'lib/rexle.rb', line 1031

def texts()

 r = @child_elements.select do |x|
    x.is_a? String or x.is_a? Rexle::CData
  end

  r.map do |x|
    def x.unescape()
      s = self.to_s.clone
      %w(&lt; < &gt; > &amp; & &apos; ').each_slice(2){|x| s.gsub!(*x)}
      s
    end
  end

  return r
end

#to_aObject



1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
# File 'lib/rexle.rb', line 1076

def to_a()

  e = [String.new(self.name), Hash.new(self.attributes)]

  if self.cdatas.any? then
    e.concat self.cdatas.map {|cdata| ['![', {}, cdata] }
  end

  [*e, *scan_to_a(self.children)]
end

#xml(options = {}) ⇒ Object Also known as: to_s



1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/rexle.rb', line 1087

def xml(options={})

  h = {
    Hash: lambda {|x|
      o = {pretty: false}.merge(x)
      msg = o[:pretty] == false ? :doc_print : :doc_pretty_print

      method(msg).call(self.children)
    },
    String: lambda {|x|
      r = self.element(x)
      r ? r.xml : ''
    }
  }
  h[options.class.to_s.to_sym].call options
end

#xpath(path, rlist = [], &blk) ⇒ Object



434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/rexle.rb', line 434

def xpath(path, rlist=[], &blk)

  #@log.debug 'inside xpath ' + path.inspect

  r = filter_xpath(path, rlist=[], &blk)
  #@log.debug 'after filter_xpath : ' + r.inspect

  if r.is_a?(Array) then

    Recordset.new(r.compact)

  else
    r
  end

end