axl main logo

axl.AttrCursor — PyAxlAttrCursor class: xml node attributes iterator

Intro

axl.AttrCursor class represents an iterator cursor that maintains state of the current element selected. It is created using a node (axl.Node) and later calls to axl.AttrCursor.next() and axl.AttrCursor.has_item() are used to check all attributes stored on a node:

# get node
node   = doc.get ("/document/child")

# create the cursor
cursor = node.attr_cursor_new ()
while cursor.has_item ():
      # print content
      print ("found attribute: " + cursor.key + "=" + cursor.value)

      # next item
      cursor.next ()

Module API

class axl.AttrCursor
first()

Set the cursor to point to the first attribute.

nexut()

Set the cursor to point to the next attribute.

has_item()

Check if the cursor is pointing to an item (or previous call to axl.AttrCursor.next() has succeeded.

Return type:Returns True in the case the cursor points to an item. Otherwise, False is returned. The method returns False once the cursor have iterated over all attributes.
has_next()

Check if the cursor points to an item that has a next attribute.

Return type:Returns True in the case there are a next item. Otherwise, False is returned.
key

(Read only attribute) (String) Allows to get the current attribute name pointed by the cursor.

value

(Read only attribute) (String) Allows to get the value associated to the attribute pointed by the cursor.

Table Of Contents

Previous topic

axl.Node — PyAxlNode class: XML node instance

Next topic

axl.Dtd — PyAxlDtd class: DTD support

This Page