XML
-
class
compas.files.XML(reader)[source] Bases:
objectRead XML files.
This class simplifies reading XML files and strings across different Python implementations.
- Attributes
reader (
XMLReader) – Reader used to process the XML file or string.
Examples
>>> from compas.files import XML >>> xml = XML.from_string("<Main><Title>Test</Title></Main>") >>> xml.root.tag 'Main'Methods
__init__(reader)Initialize self.
from_file(source)Read XML from a file path or file-like object.
from_string(text)Read XML from a string.
to_string([encoding])Generate a string representation of this XML instance, including all sub-elements.