XML
- class compas.files.XML(filepath=None)[source]
Bases:
objectRead XML files.
This class simplifies reading XML files and strings across different Python implementations.
- Attributes
Examples
>>> from compas.files import XML >>> xml = XML.from_string("<Main><Title>Test</Title></Main>") >>> xml.root.tag 'Main'Methods
from_file(source)Read XML from a file path or file-like object.
from_string(text)Read XML from a string.
read()Read XML from a file path or file-like object, stored in the attribute
filepath.to_file([prettify])Writes the string representation of this XML instance, including all sub-elements, to the file path in the associated XML object.
to_string([encoding, prettify])Generate a string representation of this XML instance, including all sub-elements.
write([prettify])Writes the string representation of this XML instance, including all sub-elements, to the file path in the associated XML object.