![]() |
ARSA Language
2.8
(Encryption, GPU and Web 3.0)
|
#include <xml.h>
Public Member Functions | |
| int | xml (const char *filename) |
| loading xml from file More... | |
| int | xml (const char *str) |
| loading xml from buffer More... | |
| int | json (const char *filename) |
| loading json from file More... | |
| int | json (const char *str) |
| loading json from buffer More... | |
| bool | save (int doc_id, const char *filename) |
| saving xml to file More... | |
| bool | save_json (int doc_id, const char *filename) |
| saving json to file More... | |
| bool | close (int doc_id) |
| close and free memory xml document functions: xml(), xml.json() and xml.new() from. More... | |
| bool | close_node (int node_id) |
| close and free memory xml node. More... | |
| bool | close_array (int array_id) |
| close and free memory xml nodes array functions: xml.get_node_array() from. More... | |
| int | first (int doc_id) |
| get xml root node from doc id. More... | |
| int | first_child (int node_id) |
| get xml root node from node id. More... | |
| int | next_child (int node_id) |
| get next xml child in this node id. More... | |
| int | get_node (int node_id, const char *node_name) |
| get first xml child from all childs in this node id. More... | |
| int | get_array (int node_id, const char *node_name) |
| get all xml childs with same name from this node id. MUST call xml.close_array() after used for memory free. More... | |
| const char * | get_name (int node_id) |
| get name of this node id More... | |
| const char * | get_value (int node_id) |
| get value of this node id More... | |
| const char * | get_att (int node_id, const char *att_name) |
| get value from attribute of this node id More... | |
| int | new () |
| allocate empty xml document. More... | |
| int | new_node (int root_id, const char *node_name, const char *value="") |
| add xml node with a name to root node and return new node as id. More... | |
| bool | new_att (int node_id, const char *att_name, const char *att_value) |
| add attribute to xml node by attribute name and value. More... | |
| int | add_child (int doc_id, const char *node_name) |
| add xml node with a name to document node and return new node as id. More... | |
| int | insert_child (int root_id, int child_id) |
| insert xml node to another root node and return new node as id. More... | |
| bool | set_value (int node_id, const char *value) |
| set value to xml node. More... | |
| bool | set_att_value (int node_id, const char *att_name, const char *att_value) |
| set attribute value to this node id. More... | |
| int | get_node_count (int node_id, const char *node_name) |
| get node count of this xml node. More... | |
| int | get_array_count (int array_id) |
| get array count. More... | |
| int | get_array_element (int array_id, int index) |
| get xml node from array with index. More... | |
| void | for (int array_id, void *function) |
| get xml node from array with for loop. More... | |
| const char * | value (int node_id, const char *path) |
| get value of this path, use last path as element name More... | |
| int | count (int node_id, const char *path) |
| get array count from path. More... | |
| int | array (int node_id, const char *path) |
| get all xml childs with same path, use last path as element name. MUST call xml.close_array() after used for memory free. Example get at: xml.value() More... | |
| const char * | array_value (int array_id, int array_num, const char *path) |
| get value in array follow path More... | |
| void | log (int id, const char *option="xml") |
| debug and print xml or json buffer in log window More... | |
| void | logarray (int array_id, const char *option="xml") |
| debug and print array of xml or json buffer in log window More... | |
| const char * | tostring (int doc_id) |
| saving xml to string buffer More... | |
| const char * | tostringjson (int doc_id) |
| saving json to string buffer More... | |
| bool | fset (const char *path, const char *value, const char *filename, const char *option="xml", bool push_back=false) |
| set value to path at file immediately. More... | |
| const char * | fget (const char *path, const char *filename, const char *option="xml") |
| get value from path in file immediately. More... | |
| int | fcount (const char *path, const char *filename, const char *option="xml") |
| get path count in file immediately. More... | |
| bool | ferase (const char *path, const char *filename, const char *option="xml") |
| erase path in file immediately. More... | |
| bool | fsave (const char *src_filename, const char *src_option, const char *dest_filename, const char *dest_option) |
| convert file format to another file format. More... | |
| int xml::xml | ( | const char * | filename | ) |
loading xml from file
| filename | name of xml file want to operator |
| int xml::xml | ( | const char * | str | ) |
loading xml from buffer
| str | xml syntax buffer that want to operator |
add xml node with a name to document node and return new node as id.
| doc_id | id of doc node, doc_id from functions: xml(), xml.json() and xml.new() |
| node_name | new name of xml node |
get all xml childs with same path, use last path as element name.
MUST call xml.close_array() after used for memory free.
Example get at: xml.value()
| node_id | id of xml node |
| path | path in xml or json that you want read value. |
get value in array follow path
| array_id | id of array xml node |
| array_num | array slot |
| path | path inside array xml or json that you want read value. |
| bool xml::close | ( | int | doc_id | ) |
close and free memory xml document functions: xml(), xml.json() and xml.new() from.
| doc_id | id of xml document, doc_id from functions: xml(), xml.json() and xml.new() |
| bool xml::close_array | ( | int | array_id | ) |
close and free memory xml nodes array functions: xml.get_node_array() from.
| array_id | id of array nodes |
| bool xml::close_node | ( | int | node_id | ) |
close and free memory xml node.
| node_id | id of xml node |
get array count from path.
| node_id | id of xml node |
| path | path in xml or json that you want read value. |
| int xml::fcount | ( | const char * | path, |
| const char * | filename, | ||
| const char * | option = "xml" |
||
| ) |
get path count in file immediately.
| path | path that you want to operate. |
| filename | name of file that you want to operate. |
| option | file type xml or json. default: xml. |
| bool xml::ferase | ( | const char * | path, |
| const char * | filename, | ||
| const char * | option = "xml" |
||
| ) |
erase path in file immediately.
| path | path that you want to operate. |
| filename | name of file that you want to operate. |
| option | file type xml or json. default: xml. |
| const char* xml::fget | ( | const char * | path, |
| const char * | filename, | ||
| const char * | option = "xml" |
||
| ) |
get value from path in file immediately.
| path | path that you want to operate. |
| filename | name of file that you want to operate. |
| option | file type xml or json. default: xml. |
get xml root node from doc id.
| doc_id | id of xml document, doc_id from functions: xml(), xml.json() and xml.new() |
get xml root node from node id.
| node_id | id of xml node |
| void xml::for | ( | int | array_id, |
| void * | function | ||
| ) |
get xml node from array with for loop.
| array_id | id of xml array from function: xml.get_node_array() |
| function | call the function until end loop. Automatic built-in index loop each, can using "null" with function: xml.get_array_element() Using break() or return() to stop them. |
| bool xml::fsave | ( | const char * | src_filename, |
| const char * | src_option, | ||
| const char * | dest_filename, | ||
| const char * | dest_option | ||
| ) |
convert file format to another file format.
| src_filename | name of source file that you want to operate. |
| src_option | source file type xml or json. |
| dest_filename | name of destination file that you want to save as a new file. |
| dest_option | destination file type xml or json. |
| bool xml::fset | ( | const char * | path, |
| const char * | value, | ||
| const char * | filename, | ||
| const char * | option = "xml", |
||
| bool | push_back = false |
||
| ) |
set value to path at file immediately.
| path | path that you want to operate. |
| value | a value that want set to path. |
| filename | name of file that you want to operate. |
| option | file type xml or json. default: xml. |
| push_back | true is push_back or false is overwrite. default: false (mean overwrite). |
get all xml childs with same name from this node id.
MUST call xml.close_array() after used for memory free.
| node_id | id of xml node |
| node_name | name of xml node that want to operator |
get array count.
| array_id | id of xml array from functions: xml.get_node_array() |
get xml node from array with index.
| array_id | id of xml array from function: xml.get_node_array() |
| index | array index, do not over array size-1. May be size from function: xml.get_array_count() This parameter can be "null" using inside function: xml.for() |
| const char* xml::get_att | ( | int | node_id, |
| const char * | att_name | ||
| ) |
get value from attribute of this node id
| node_id | id of xml node |
| att_name | name of xml attribute that want to operator |
| const char* xml::get_name | ( | int | node_id | ) |
get name of this node id
| node_id | id of xml node |
get first xml child from all childs in this node id.
| node_id | id of xml node |
| node_name | name of xml node that want to operator |
get node count of this xml node.
| node_id | id of xml node |
| node_name | name of xml node that want to operator, empty node_name is get all node |
| const char* xml::get_value | ( | int | node_id | ) |
get value of this node id
| node_id | id of xml node |
insert xml node to another root node and return new node as id.
| root_id | id of root xml node |
| child_id | id of child xml node |
| int xml::json | ( | const char * | filename | ) |
loading json from file
| filename | name of json file want to operator |
| int xml::json | ( | const char * | str | ) |
loading json from buffer
| str | json syntax buffer that want to operator |
| void xml::log | ( | int | id, |
| const char * | option = "xml" |
||
| ) |
debug and print xml or json buffer in log window
| id | map id. |
| option | file type xml or json. default: xml |
| void xml::logarray | ( | int | array_id, |
| const char * | option = "xml" |
||
| ) |
debug and print array of xml or json buffer in log window
| array_id | id of array nodes |
| option | file type xml or json. default: xml |
| int xml::new | ( | ) |
allocate empty xml document.
| bool xml::new_att | ( | int | node_id, |
| const char * | att_name, | ||
| const char * | att_value | ||
| ) |
add attribute to xml node by attribute name and value.
| node_id | id of xml node |
| att_name | name of new attribute. |
| att_value | name of new value to attribute. |
add xml node with a name to root node and return new node as id.
| root_id | id of root node |
| node_name | new name of xml node |
| value | a value of xml node that want to set. |
get next xml child in this node id.
| node_id | id of xml node |
| bool xml::save | ( | int | doc_id, |
| const char * | filename | ||
| ) |
saving xml to file
| doc_id | id of xml document, doc_id from functions: xml(), xml.json() and xml.new() |
| filename | name of file want to operator |
| bool xml::save_json | ( | int | doc_id, |
| const char * | filename | ||
| ) |
saving json to file
| doc_id | id of xml document, doc_id from functions: xml(), xml.json() and xml.new() |
| filename | name of file want to operator |
| bool xml::set_att_value | ( | int | node_id, |
| const char * | att_name, | ||
| const char * | att_value | ||
| ) |
set attribute value to this node id.
| node_id | id of xml node |
| att_name | name of attribute that must exist!. |
| att_value | name of new value to this attribute. |
| bool xml::set_value | ( | int | node_id, |
| const char * | value | ||
| ) |
set value to xml node.
| node_id | id of xml node. |
| value | a value of xml node that want to set. |
| const char* xml::tostring | ( | int | doc_id | ) |
saving xml to string buffer
| doc_id | id of xml document, doc_id from functions: xml(), xml.json() and xml.new() |
| const char* xml::tostringjson | ( | int | doc_id | ) |
saving json to string buffer
| doc_id | id of xml document, doc_id from functions: xml(), xml.json() and xml.new() |
| const char* xml::value | ( | int | node_id, |
| const char * | path | ||
| ) |
get value of this path, use last path as element name
| node_id | id of xml node |
| path | path in xml or json that you want read value. |
Example 1: Load json from file with utf8.
Result
JSon: jsonarray.txt
Example 2:
Result
JSon: