def get_xpath(self, type, instance=True):
        '''get_xpath

        High-level api: Delete four attributes from an Element node if they
        exist: operation, insert, value and key.

        Parameters
        ----------

        element : `Element`
            The Element node needs to be looked at.

        Returns
        -------

        Element
            The Element node is returned after processing.
        '''

        """
        This is the lxml xpath format
        This is the YTool xpath format
        >>> assert(schema_path == 'openconfig-interfaces/interfaces/'
                          'interface/oc-eth:ethernet/'
                          'oc-eth:config/oc-eth:port-speed')
        """

        def convert(default_ns, nodes, type):
            ret = ''
            for index, node in enumerate(nodes):
                default_ns, id = self.device.convert_tag(default_ns, node.tag,
                                                         dst=type)
                ret += '/' + id
                if self.is_config and type != Tag.YTOOL:
                    n = Composer(self.device, node)
                    if n.schema_node is not None:
                        if n.schema_node.get('type') == 'leaf-list' and \
                           not (index == len(nodes)-1 and not instance):
                            ret += '[text()="{}"]'.format(node.text)
                        elif n.schema_node.get('type') == 'list' and \
                             not (index == len(nodes)-1 and not instance):
                            for key in n.keys:
                                id = self.device.convert_tag(default_ns, key,
                                                             dst=type)[1]
                                ret += '[{}="{}"]'.format(id,
                                                          node.find(key).text)
            return ret

        nodes = list(reversed(list(self.node.iterancestors())))[1:] + \
                [self.node]
        if type == Tag.YTOOL:
            return self.model_name + convert(self.model_ns, nodes, type)
        else:
            return convert('', nodes, type)
def get_xpath ( self , type , instance = True ) : """
        This is the lxml xpath format
        This is the YTool xpath format
        >>> assert(schema_path == 'openconfig-interfaces/interfaces/'
                          'interface/oc-eth:ethernet/'
                          'oc-eth:config/oc-eth:port-speed')
        """ def convert ( default_ns , nodes , type ) : ret = '' for index , node in enumerate ( nodes ) : default_ns , id = self . device . convert_tag ( default_ns , node . tag , dst = type ) ret += '/' + id if self . is_config and type != Tag . YTOOL : n = Composer ( self . device , node ) if n . schema_node is not None : if n . schema_node . get ( 'type' ) == 'leaf-list' and not ( index == len ( nodes ) - 1 and not instance ) : ret += '[text()="{}"]' . format ( node . text ) elif n . schema_node . get ( 'type' ) == 'list' and not ( index == len ( nodes ) - 1 and not instance ) : for key in n . keys : id = self . device . convert_tag ( default_ns , key , dst = type ) [ 1 ] ret += '[{}="{}"]' . format ( id , node . find ( key ) . text ) return ret nodes = list ( reversed ( list ( self . node . iterancestors ( ) ) ) ) [ 1 : ] + [ self . node ] if type == Tag . YTOOL : return self . model_name + convert ( self . model_ns , nodes , type ) else : return convert ( '' , nodes , type )
get_xpath

        High-level api: Delete four attributes from an Element node if they
        exist: operation, insert, value and key.

        Parameters
        ----------

        element : `Element`
            The Element node needs to be looked at.

        Returns
        -------

        Element
            The Element node is returned after processing.