Class: XMLBuilder::PathParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ec2/amitools/xmlbuilder.rb

Overview

Parses an xpath like expression

Defined Under Namespace

Classes: Attribute, Document, Element, Node

Class Method Summary collapse

Class Method Details

.parse(path) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ec2/amitools/xmlbuilder.rb', line 71

def PathParser.parse(path)
  nodes = path.split('/')
  @nodes = []
  first = true

  while (nodes.length > 0)
    node = Node.new(first, nodes)
    first = false
    @nodes << Document.new() if node.document
    @nodes << Element.new(node.element, node.index) if node.element
    @nodes << Attribute.new(node.attribute) if node.attribute
  end
  @nodes
end