XMLParser¶
Low-level class for creating parsers forXML files.
Description¶
This class can serve as base to make custom XML parsers. Since XML is a very flexible standard, this interface is low-level so it can be applied to any possible schema.
Methods¶
has_attribute(String name)const | |
open_buffer(PoolByteArray buffer) | |
read() | |
void |
Enumerations¶
enumNodeType:
NODE_NONE =0 --- There's no node (no file or buffer opened).
NODE_ELEMENT =1 --- Element (tag).
NODE_ELEMENT_END =2 --- End of element.
NODE_TEXT =3 --- Text node.
NODE_COMMENT =4 --- Comment node.
NODE_CDATA =5 --- CDATA content.
NODE_UNKNOWN =6 --- Unknown node.
Method Descriptions¶
Gets the amount of attributes in the current element.
Gets the name of the attribute specified by the index inidx argument.
Gets the value of the attribute specified by the index inidx argument.
Gets the current line in the parsed file (currently not implemented).
Gets the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute.
Gets the value of a certain attribute of the current element by name. This will return an emptyString if the attribute is not found.
Gets the contents of a text node. This will raise an error in any other type of node.
Gets the name of the current element node. This will raise an error if the current node type is neitherNODE_ELEMENT norNODE_ELEMENT_END.
Gets the byte offset of the current node since the beginning of the file or buffer.
NodeTypeget_node_type()
Gets the type of the current node. Compare withNodeType constants.
Check whether the current element has a certain attribute.
Check whether the current element is empty (this only works for completely empty tags, e.g.<element\>).
Opens an XML file for parsing. This returns an error code.
Erroropen_buffer(PoolByteArray buffer)
Opens an XML raw buffer for parsing. This returns an error code.
Errorread()
Reads the next node of the file. This returns an error code.
Moves the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.
voidskip_section()
Skips the current section. If the node contains other elements, they will be ignored and the cursor will go to the closing of the current element.