RSpec.create(self)
if self.type:
self.xml.set('type', self.type)
-
+
+ def remove_element(self, element_name, root_node=None):
+ if not element_name.startswith('rspecv2:'):
+ element_name = 'rspecv2:' + element_name
+ RSpec.remove_element(self, element_name, root_node)
+
def get_network(self):
network = None
nodes = self.xml.xpath('//rspecv2:node[@component_manager_uuid][1]', namespaces=self.namespaces)
tree = etree.parse(StringIO(rspec), parser)
except:
raise InvalidRSpec('Must specify a xml file or xml string. Received: ' + rspec )
-
self.xml = tree.getroot()
if namespaces:
self.namespaces = namespaces
+ def xpath(self, xpath):
+ return this.xml.xpath(xpath, namespaces=self.namespaces)
+
def add_attribute(self, elem, name, value):
"""
Add attribute to specified etree element
if not root_node:
root_node = self.xml
- elements = root_node.xpath('//rspecv2:%s | //%s' % (element_name, element_name), \
- namespaces=self.namespaces)
+ elements = root_node.xpath('//%s ' % element_name, namespaces=self.namespaces)
for element in elements:
parent = element.getparent()
parent.remove(element)