Lines Matching refs:element
8 2. Element represents a single node in this tree.
11 usually done on the ElementTree level. Interactions with a single XML element
12 and its sub-elements are done on the Element level.
14 Element is a flexible container object designed to store hierarchical data
16 dictionary. Each Element has a number of properties associated with it:
18 'tag' - a string containing the element's name.
20 'attributes' - a Python dictionary storing the element's attributes.
22 'text' - a string containing the element's text content.
24 'tail' - an optional string containing text after the element's end tag.
28 To create an element instance, use the Element constructor,
31 You can also use the ElementTree class to wrap an element structure
77 "Element", "ElementTree",
119 def iselement(element):
120 """Return True if *element* appears to be an Element."""
121 return hasattr(element, 'tag')
124 class Element:
125 """An XML element.
127 This class is the reference implementation of the Element interface.
129 An element's length is its number of subelements. That means if you
130 want to check if an element is truly empty, you should check BOTH
133 The element tag, attribute names, and attribute values can be either
136 *tag* is the element name. *attrib* is an optional dictionary containing
137 element attributes. *extra* are additional element attributes given as
146 """The element's name."""
149 """Dictionary of the element's attributes."""
161 Text after this element's end tag, but before the next sibling element's
182 """Create a new element with the same type.
184 *tag* is a string containing the element name.
185 *attrib* is a dictionary containing the element attributes.
193 """Return copy of current element.
219 def __setitem__(self, index, element):
221 # for elt in element:
224 # assert iselement(element)
225 self._children[index] = element
231 """Add *subelement* to the end of this element.
233 The new element will appear in document order after the last existing
235 but before the end tag for this element.
247 for element in elements:
248 self._assert_is_element(element)
260 raise TypeError('expected an Element, not %s' % type(e).__name__)
269 the parent element.
271 ValueError is raised if a matching element could not be found.
274 # assert iselement(element)
291 """Find first matching element by tag name or path.
293 *path* is a string having either an element tag or an XPath,
296 Return the first matching element, or None if no element was found.
302 """Find text for first matching element by tag name or path.
304 *path* is a string having either an element tag or an XPath,
305 *default* is the value to return if the element was not found,
308 Return text content of first matching element, or default value if
309 none was found. Note that if an element is found having no text
318 *path* is a string having either an element tag or an XPath,
329 *path* is a string having either an element tag or an XPath,
338 """Reset element.
349 """Get element attribute.
362 """Set element attribute.
381 """Get element attributes as a sequence.
394 The iterator loops over the element and all subelements in document
426 The iterator loops over the element and all subelements in document
444 """Subelement factory which creates an element instance, and appends it
447 The element tag, attribute names, and attribute values can be either
450 *parent* is the parent element, *tag* is the subelements name, *attrib* is
451 an optional directory containing element attributes, *extra* are
457 element = parent.makeelement(tag, attrib)
458 parent.append(element)
459 return element
463 """Comment element factory.
465 This function creates a special element which the standard serializer
471 element = Element(Comment)
472 element.text = text
473 return element
477 """Processing Instruction element factory.
479 This function creates a special element which the standard serializer
486 element = Element(ProcessingInstruction)
487 element.text = target
489 element.text = element.text + " " + text
490 return element
544 """An XML element hierarchy.
549 *element* is an optional root element node,
554 def __init__(self, element=None, file=None):
555 # assert element is None or iselement(element)
556 self._root = element # first node
561 """Return root element of this tree."""
564 def _setroot(self, element):
565 """Replace root element of this tree.
568 with the given element. Use with care!
571 # assert iselement(element)
572 self._root = element
575 """Load external XML document into element tree.
582 Returns the root element of the given source document.
612 """Create and return tree iterator for the root element.
634 """Find first matching element by tag name or path.
636 Same as getroot().find(path), which is Element.find()
638 *path* is a string having either an element tag or an XPath,
641 Return the first matching element, or None if no element was found.
656 """Find first matching element by tag name or path.
658 Same as getroot().findtext(path), which is Element.findtext()
660 *path* is a string having either an element tag or an XPath,
663 Return the first matching element, or None if no element was found.
680 Same as getroot().findall(path), which is Element.findall().
682 *path* is a string having either an element tag or an XPath,
702 Same as getroot().iterfind(path), which is element.iterfind()
704 *path* is a string having either an element tag or an XPath,
727 """Write element tree to a file as XML.
864 qnames[qname] = tag # default element
1120 def tostring(element, encoding=None, method=None, *,
1122 """Generate string representation of XML element.
1127 *element* is an Element instance, *encoding* is an optional output
1135 ElementTree(element).write(stream, encoding, method=method,
1156 def tostringlist(element, encoding=None, method=None, *,
1160 ElementTree(element).write(stream, encoding, method=method,
1166 """Write element tree or element structure to sys.stdout.
1170 *elem* is either an ElementTree, or a single Element. The exact output
1188 """Parse XML document into element tree.
1282 Unlike XMLParser, does not return the root element. Use
1310 Returns an Element instance.
1325 Returns an (Element, dict) tuple, in which the
1326 dict maps element id:s to elements.
1349 Returns an Element instance.
1362 """Generic element structure builder.
1365 calls to a well-formed element structure.
1367 You can use this class to build an element structure using a custom XML
1370 *element_factory* is an optional element factory which is called
1371 to create new Element instances, as necessary.
1376 self._elem = [] # element stack
1377 self._last = None # last element
1380 element_factory = Element
1384 """Flush builder buffers and return toplevel document Element."""
1386 assert self._last is not None, "missing toplevel element"
1402 """Add text to current element."""
1406 """Open new element and return it.
1408 *tag* is the element name, *attrs* is a dict containing element
1421 """Close and return current Element.
1423 *tag* is the element name.
1438 """Element structure builder for XML source data based on the expat parser.
1635 """Finish feeding data to parser and return element structure."""
1654 # Element is going to be shadowed by the C implementation. We need to keep
1657 _Element_Py = Element
1659 # Element, SubElement, ParseError, TreeBuilder, XMLParser