Unigine.Xml Class
As Unigine extensively uses XML for storing different types of data, it also provides functionality for parsing and saving files of this type.
See Also#
- C++ API sample <UnigineSDK>/source/samples/Api/Systems/Xml
- C# API sample <UnigineSDK>/source/csharp/samples/Api/Systems/Xml
Xml Class
Properties
quat QuatData#
A quaternion interpretation of data stored in the node.
set
Sets a quaternion content for the node. This can be done only for nodes with no children.
set value -
Content to set.
dmat4 DMat4Data#
A dmat4 matrix interpretation of data stored in the node.
set
Sets a dmat4 matrix content for the node. This can be done only for nodes with no children.
set value -
Content to set.
mat4 Mat4Data#
A mat4 matrix interpretation of data stored in the node.
set
Sets a mat4 matrix content for the node. This can be done only for nodes with no children.
set value -
Content to set.
ivec4 IVec4Data#
A ivec4 interpretation of data stored in the node.
set
Sets a ivec4 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
ivec3 IVec3Data#
A ivec3 interpretation of data stored in the node.
set
Sets a ivec3 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
ivec2 IVec2Data#
A ivec2 interpretation of data stored in the node.
set
Sets a ivec2 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
dvec4 DVec4Data#
A dvec4 interpretation of data stored in the node.
set
Sets a dvec4 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
dvec3 DVec3Data#
A dvec3 interpretation of data stored in the node.
set
Sets a dvec3 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
dvec2 DVec2Data#
A dvec2 interpretation of data stored in the node.
set
Sets a dvec2 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
vec4 Vec4Data#
A vec4 interpretation of data stored in the node.
set
Sets a vec4 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
vec3 Vec3Data#
A vec3 interpretation of data stored in the node.
set
Sets a vec3 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
vec2 Vec2Data#
A vec2 interpretation of data stored in the node.
set
Sets a vec2 content for the node. This can be done only for nodes with no children.
set value -
Content to set.
double DoubleData#
A double interpretation of data stored in the node.
set
Sets a double content for the node. This can be done only for nodes with no children.
set value -
Content to set.
float FloatData#
A float interpretation of data stored in the node.
set
Sets a float content for the node. This can be done only for nodes with no children.
set value -
Content to set.
long LongData#
A long interpretation of data stored in the node.
set
Sets a long content for the node. This can be done only for nodes with no children.
set value -
Content to be set.
bool BoolData#
A boolean interpretation of data stored in the node.
set
Sets a boolean content for the node. This can be done only for nodes with no children.
set value -
Content to set. Any non-zero value means true, the zero value means false.
string Data#
Gets a data from the XML file.
set
Sets an XML data.
set value -
The XML data.
int NumArgs#
A number of arguments.
int NumChildren#
The number of the node children.
string Name#
A name of the node.
set
Sets a name of the node.
set value -
Node name.
Members
static Xml ( ) #
Default constructor that creates an empty instance.static Xml ( string name, string args = 0 ) #
Creates an XML tree with a given node as a root.Arguments
- string name - Name of the node that will be a root.
- string args - Optional arguments to the root node. If provided, they should be in this form:
arg1=\"value1\" arg2=\"value2\" …
If values do not contain spaces, escaped quotes can be omitted.
static Xml ( Xml xml ) #
Constructor. Creates a path out of the specified XML file.Arguments
- Xml xml - XML file instance.
bool SetArg ( string name, string value ) #
Sets a literal value of a given argument.Arguments
- string name - The XML argument name.
- string value - The XML argument value.
Return value
Returns 1 if the argument is set successfully; otherwise, 0.string GetArg ( string name ) #
Gets an XML argument.Arguments
- string name - The XML argument name.
Return value
Value of the argument, if it is found; otherwise, 0.bool IsArg ( string name ) #
Checks whether an argument with a given name exists.Arguments
- string name - Name to check.
Return value
1 if the argument exists; otherwise, 0.void SetArgName ( int num, string name ) #
Sets the XML argument name.Arguments
- int num - The argument number.
- string name - The argument name.
string GetArgName ( int num ) #
Returns argument name by its number.Arguments
- int num - Argument number.
Return value
Argument name.void SetArgValue ( int num, string value ) #
Sets the XML argument value.Arguments
- int num - The argument number.
- string value - The argument value.
string GetArgValue ( int num ) #
Returns the XML argument value.Arguments
- int num - The argument number.
Return value
Argument value.bool SetBoolArg ( string name, bool value ) #
Sets a value of a given boolean argument.Arguments
- string name - Name of an argument.
- bool value - Value of the argument. Any non-zero value means true, the zero value means false.
Return value
Returns 1 if the operation was successful; otherwise, 0.bool GetBoolArg ( string name, bool value ) #
Returns a value of a given boolean argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
- bool value - Default value of the argument.
Return value
1 if the argument has a value 1, true or TRUE; 0, if the argument has a value 0, false or FALSE; otherwise, 0.bool GetBoolArg ( string name ) #
Returns a value of a given boolean argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
1 if the argument has a value 1, true or TRUE; 0, if the argument has a value 0, false or FALSE; otherwise, 0.Xml GetChild ( string name ) #
Returns the child of the XML tree.Arguments
- string name - The child number.
Return value
XML instance.Xml GetChild ( int num ) #
Returns a child node by its name or index number in the child list.To check, if a child with a given name exists, use the isChild() method.
Arguments
- int num - The child number.
Return value
Target child node, if it is found; otherwise, 0.bool IsChild ( string name ) #
Checks if a child element with a given name exists.Arguments
- string name - Element name to check.
Return value
string GetChildData ( string name ) #
Gets the data from the XML child node.Arguments
- string name - Name of the child node.
Return value
The value of the child node.bool SetDMat4Arg ( string name, dmat4 value ) #
Sets a value of a given dmat4 argument.Arguments
- string name - Name of an argument.
- dmat4 value - Value of an argument.
Return value
Always 1.dmat4 GetDMat4Arg ( string name ) #
Returns a value of a given dmat4 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetDoubleArg ( string name, double value ) #
Sets a value of a given double argument.Arguments
- string name - Name of an argument.
- double value - Value of an argument.
Return value
Always 1.double GetDoubleArg ( string name, double value ) #
Returns a value of a given double argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
- double value - Default value of the argument.
Return value
Argument value.double GetDoubleArg ( string name ) #
Returns a value of a given double argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetDoubleArrayArg ( string name, double[] src ) #
Sets a vector of double as a value of a given argument.Arguments
- string name - Name of an argument.
- double[] src - Reference to a vector with double components.
Return value
Always 1.bool GetDoubleArrayArg ( string name, string name ) #
Returns a set of double values stored in an argument and puts them in a vector.Arguments
- string name - Name of a target argument.
- string name
Return value
1 if dest contains anything; otherwise, 0.bool SetDoubleArrayData ( double[] src ) #
Sets a vector of double components as a content for the node. This can be done only for nodes with no children.Arguments
- double[] src - Reference to a vector with double components.
Return value
1 if the content is set successfully; otherwise, 0.bool GetDoubleArrayData ( out double[] dest ) #
Returns an interpretation of data stored in the node as a vector of double components.Arguments
- out double[] dest - Reference to a vector with double components.
Return value
1 if dest contains anything; otherwise, 0.bool SetDVec2Arg ( string name, dvec2 value ) #
Sets a value of a given dvec2 argument.Arguments
- string name - Name of an argument.
- dvec2 value - Value of an argument.
Return value
Always 1.dvec2 GetDVec2Arg ( string name ) #
Returns a value of a given dvec2 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetDVec3Arg ( string name, dvec3 value ) #
Sets a value of a given dvec3 argument.Arguments
- string name - Name of an argument.
- dvec3 value - Value of an argument.
Return value
Always 1.dvec3 GetDVec3Arg ( string name ) #
Returns a value of a given dvec3 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetDVec4Arg ( string name, dvec4 value ) #
Sets a value of a given dvec4 argument.Arguments
- string name - Name of an argument.
- dvec4 value - Value of an argument.
Return value
Always 1.dvec4 GetDVec4Arg ( string name ) #
Returns a value of a given dvec4 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetFloatArg ( string name, float value ) #
Sets a value of a given float argument.Arguments
- string name - Name of an argument.
- float value - Value of an argument.
Return value
Always 1.float GetFloatArg ( string name, float value ) #
Returns a value of a given float argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
- float value - Default value of the argument.
Return value
Argument value.float GetFloatArg ( string name ) #
Returns a value of a given float argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetFloatArrayArg ( string name, float[] src ) #
Sets a vector of floats as a value of a given argument.Arguments
- string name - Name of an argument.
- float[] src - Target vector.
Return value
Always 1.bool GetFloatArrayArg ( string name, out float[] dest ) #
Returns a set of float values stored in an argument and puts them in a vector.Arguments
- string name - Name of a target argument.
- out float[] dest - Target vector.
Return value
1 if dest contains anything; otherwise, 0.bool SetFloatArrayData ( float[] src ) #
Sets a vector of floats as a content for the node. This can be done only for nodes with no children.Arguments
- float[] src - A float array data.
Return value
1 if the content is set successfully; otherwise, 0.bool GetFloatArrayData ( out float[] dest ) #
Returns an interpretation of data stored in the node as a vector of floats.Arguments
- out float[] dest - Reference to a vector.
Return value
1 if dest contains anything; otherwise, 0.string GetFormattedSubTree ( string path = 0, string indent = "\t" ) #
Converts the specified XML subtree into a formatted string for "pretty printing". If no arguments are passed, the entire XML tree is converted.Arguments
- string path - Path to the XML subtree to be formatted. See the description of find() for more details.
- string indent - String to be used for indenting (e.g. "\t").
Return value
Multi-line indented output of the specified XML subtree.bool SetIntArg ( string name, int value, int radix = 10 ) #
Sets a value for a given int argument in a given number notation. By default, the decimal number notation is used.Arguments
- string name - Name of an argument.
- int value - Value of an argument.
- int radix - Radix to use when setting a value.
Return value
1 if the value is set successfully; otherwise, 0.int GetIntArg ( string name ) #
Returns a value of a given int argument.To check whether the argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.int GetIntArg ( string name, int value ) #
Returns a value of a given int argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
- int value - Default value of the argument.
Return value
Argument value.bool SetIntArrayArg ( string name, int[] src, int radix = 10 ) #
Sets an array of integers as xml argument in a given number notation. By default, the decimal number notation is used.Arguments
- string name - Name of an argument.
- int[] src - An array of integers.
- int radix - Radix to use when setting a value.
Return value
1 if the array is set successfully; otherwise, 0.bool GetIntArrayArg ( string name, out int[] dest ) #
Returns a set of int values stored in an argument and puts them in a vector.Arguments
- string name - Name of a target argument.
- out int[] dest - Reference to a vector or an array of integers.
Return value
1 if values are read successfully; otherwise, 0.bool SetIntArrayData ( int[] src, int radix ) #
Sets a vector of integers as a content for the XML node in a given number notation. By default, the decimal number notation is used. This can be done only for XML nodes with no children.Arguments
- int[] src - Reference to a vector.
- int radix - Radix to use when setting a value.
Return value
1 if the content is set successfully; otherwise, 0.bool GetIntArrayData ( out int[] dest ) #
Returns an interpretation of data stored in the node as a vector of integers.Arguments
- out int[] dest - Reference to a vector.
Return value
1 if values are read successfully; otherwise, 0.bool SetIntData ( int value, int radix = 10 ) #
Sets an integer as a content for the XML node in a given number notation. By default, the decimal number notation is used. This can be done only for XML nodes with no children.Arguments
- int value - Content to set.
- int radix - Radix to use when setting a value.
Return value
1 if the content is set successfully; otherwise, 0.bool SetIVec2Arg ( string name, ivec2 value ) #
Sets a value of a given ivec2 argument.Arguments
- string name - Name of an argument.
- ivec2 value - Value of an argument.
Return value
Always 1.ivec2 GetIVec2Arg ( string name ) #
Returns a value of a given ivec2 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetIVec3Arg ( string name, ivec3 value ) #
Sets a value of a given ivec3 argument.Arguments
- string name - Name of an argument.
- ivec3 value - Value of an argument.
Return value
Always 1.ivec3 GetIVec3Arg ( string name ) #
Returns a value of a given ivec3 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetIVec4Arg ( string name, ivec4 value ) #
Sets a value of a given ivec4 argument.Arguments
- string name - Name of an argument.
- ivec4 value - Value of an argument.
Return value
Always 1.ivec4 GetIVec4Arg ( string name ) #
Returns a value of a given ivec4 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetMat4Arg ( string name, mat4 value ) #
Sets a value of a given mat4 argument.Arguments
- string name - Name of an argument.
- mat4 value - Value of an argument.
Return value
Always 1.mat4 GetMat4Arg ( string name ) #
Returns a value of a given mat4 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.Xml GetParent ( ) #
Returns the parent of the current XML node.Return value
XML node.bool SetQuatArg ( string name, quat value ) #
Sets a value of a given quat argument.Arguments
- string name - Name of an argument.
- quat value - Value of an argument.
Return value
Always 1.quat GetQuatArg ( string name ) #
Returns a value of a given quat argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetRawData ( string data ) #
Sets a raw content for the node. Raw data will be automatically formatted as a CDATA section. This can be done only for nodes with no children.Arguments
- string data - Content to set.
Return value
1 if the content is set successfully; otherwise, 0.bool SetStringArrayArg ( string name, string[] src ) #
Sets a vector of strings as a value of a given argument in a given number notation. By default, the decimal number notation is used.Arguments
- string name - Name of an argument.
- string[] src - An array of strings.
Return value
Always 1.bool GetStringArrayArg ( string name, string[] dest ) #
Returns a set of string values stored in an argument and puts them in a vector.Arguments
- string name - Name of the string.
- string[] dest - Reference to a vector.
Return value
1 if dest contains anything; otherwise, 0.bool SetStringArrayData ( string[] src, string delimiter = "," ) #
Sets a vector of strings as a content for the node. This can be done only for nodes with no children.Arguments
- string[] src - Vector of strings.
- string delimiter - Character(s) to be used as a delimiter to split tokens.
Return value
1 if the content is set successfully; otherwise, 0.bool GetStringArrayData ( string[] dest, string delimiter = "," ) #
Returns an interpretation of data stored in the node as a vector of strings.Arguments
- string[] dest - Vector of strings.
- string delimiter - Character(s) to be used as a delimiter to split tokens.
Return value
1 if dest contains anything; otherwise, 0.string GetSubTree ( string path = 0 ) #
Dumps the node tree.Arguments
- string path - Path to the node. See the description of find() for more details.
Return value
Single-line non-indented output of the node tree. If no arguments are passed, the entire XML tree would be output.bool SetVec2Arg ( string name, vec2 value ) #
Sets a value of a given vec2 argument.Arguments
- string name - Name of an argument.
- vec2 value - Value of an argument.
Return value
Always 1.vec2 GetVec2Arg ( string name ) #
Returns a value of a given vec2 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetVec3Arg ( string name, vec3 value ) #
Sets a value of a given vec3 argument.Arguments
- string name - Name of an argument.
- vec3 value - Value of an argument.
Return value
Always 1.vec3 GetVec3Arg ( string name ) #
Returns a value of a given vec3 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetVec4Arg ( string name, vec4 value ) #
Sets a value of a given vec4 argument.Arguments
- string name - Name of an argument.
- vec4 value - Value of an argument.
Return value
Always 1.vec4 GetVec4Arg ( string name ) #
Returns a value of a given vec4 argument.To check, if an argument exists, use the isArg() method.
Arguments
- string name - Name of a target argument.
Return value
Argument value.bool SetXmlData ( string data ) #
Sets an unquoted string to data stored in the node. This string can also contain XML sub-tree with rich text formatting.Arguments
- string data - Unquoted string to set.
Return value
1 if the string is set successfully; otherwise, 0.Xml AddChild ( string name, string args = 0 ) #
Appends a new XML node to the current XML node as a child.Arguments
- string name - Name of the XML node.
- string args - Arguments of the XML node. The default value is 0.
This value should be passed if the first argument is a string
Return value
Created XML node.Xml AddChild ( Xml xml ) #
Appends a new XML node to the current XML node as a child.Arguments
- Xml xml - Argument of one of the following types:
- Xml xml - XML node.
- string name - Name of the XML node.
Return value
Created XML node.void Clear ( ) #
Clears all data associated with the node.void ClearChildren ( ) #
Clears all children of the current XML node.void ClearUnusedData ( ) #
Clears the unused nodes and arguments.void Copy ( Xml source ) #
Copies all data (name, arguments, data, flags and a child hierarchy) from the source XML node to the current one.Arguments
- Xml source - Source XML node.
string Decode ( string arg1 ) #
Decodes special XML characters (less-than, greater-than, ampersand, double-quote and apostrophe) and numeric character references.Arguments
- string arg1 - Data to decode.
Return value
Decoded string.string Encode ( string arg1 ) #
Encodes special XML characters (less-than, greater-than, ampersand, double-quote and apostrophe) to their character entity reference.Arguments
- string arg1 - Data to encode.
Return value
Encoded string.Xml Find ( string path ) #
Searches for an XML sub-tree.Arguments
- string path - Path to the XML sub-tree.
Return value
XML node.int FindArg ( string name ) #
Searches for a XML argument by its name.Arguments
- string name - XML argument name.
Return value
XML argument number.int FindChild ( string name ) #
Searches for the number of the XML node child by name.Arguments
- string name - Name of the XML node child.
Return value
The number of the XML node child if it is exists; otherwise, -1.bool Load ( string name ) #
Loads an XML document and sets the current node to be the root of the parsed tree.Arguments
- string name - File name.
Return value
1 if the file is read and parsed successfully; otherwise, 0.bool Parse ( string src ) #
Parses a string with XML mark-up and sets the current node to be the root of the parsed tree.Arguments
- string src - String with an XML content.
Return value
1 if a string is successfully parsed; otherwise 0.void PrintUnusedData ( string name ) #
Logs warnings of unused data for debugging.Arguments
- string name - Path to the file.
int RemoveArg ( string name ) #
Removes the argument with the given name from the list of the current XML node arguments.Arguments
- string name - Name of the target argument.
Return value
1 if the argument is deleted successfully; otherwise, 0.Xml RemoveChild ( Xml xml ) #
Removes a child node and its descendants from the current XML node.Arguments
- Xml xml - XML sub-tree smart pointer.
Return value
Removed child node and its descendants, if they are found; otherwise, 0.bool Save ( string name, bool binary = 0, string indent = "\t" ) #
Formats the tree of the current node and writes is to the specified file in the specified format.Arguments
- string name - Path to the file.
- bool binary - Binary format flag: use 1 to save data to a binary file, or 0 - to save it to a text file.
- string indent - String to be used for indenting (e.g. "\t").
Return value
1 if the file is written successfully; otherwise, 0.string Symbols ( string arg1 ) #
Replaces ampersand characters with character entity references.Arguments
- string arg1 - String to encode.
Return value
String which contains replaced ampersand characters with character entity references.Last update:
2020-04-10
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)