Low-level class for creating parsers for XML files.
    public class XMLParser : Reference

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.

Inheritance Chain

Constructors

    public XMLParser()

Methods

    public int GetAttributeCount()

Get the amount of attributes in the current element.

    public string GetAttributeName(int idx)

Get the name of the attribute specified by the index in idx argument.

    public string GetAttributeValue(int idx)

Get the value of the attribute specified by the index in idx argument.

    public int GetCurrentLine()

Get the current line in the parsed file (currently not implemented).

    public string GetNamedAttributeValue(string name)

Get the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute.

    public string GetNamedAttributeValueSafe(string name)

Get the value of a certain attribute of the current element by name. This will return an empty String if the attribute is not found.

    public string GetNodeData()

Get the contents of a text node. This will raise an error in any other type of node.

    public string GetNodeName()

Get the name of the current element node. This will raise an error if the current node type is not NODE_ELEMENT nor NODE_ELEMENT_END

    public int GetNodeOffset()

Get the byte offset of the current node since the beginning of the file or buffer.

    public NodeType GetNodeType()

Get the type of the current node. Compare with NODE_* constants.

    public bool HasAttribute(string name)

Check whether or not the current element has a certain attribute.

    public bool IsEmpty()

Check whether the current element is empty (this only works for completely empty tags, e.g. <element >).

    public Error Open(string file)

Open a XML file for parsing. This returns an error code.

    public Error OpenBuffer(byte[] buffer)

Open a XML raw buffer for parsing. This returns an error code.

    public Error Read()

Read the next node of the file. This returns an error code.

    public Error Seek(int position)

Move the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.

    public void SkipSection()

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.

Inner Types

NodeType

Name Value Description
None 0 There’s no node (no file or buffer opened)
Element 1 Element (tag)
ElementEnd 2 End of element
Text 3 Text node
Comment 4 Comment node
Cdata 5 CDATA content
Unknown 6 Unknown node
Tags: