xml.bi

Summary
xml.bi
LicenseCopyright © 2009, FreeBASIC Extended Library Development Group
Macros
FBEXT_XML_IS_WHITESPACEreturns true if character is a whitespace character.
ext.xml
Enumerations
charContains the ASCII characters that are special or must be escaped in XML.
Functions
encode_entitiesEncodes special characters in a string to their proper form.
decode_entitiesDecodes special characters in a string to their standard form.
encode_utf8Encodes a UTF-8 character to its string representation.
decode_utf8Decodes a UTF-8 character from its string representation.
Enumerations
node_type_eRepresents the different types of nodes supported.
nodeChild XML class, branch and leaf nodes.
Variables
tagContains this child’s tag name
Functions
node_typeAccess the type of the node.
Properties
attributeAccess the value of an attribute of the node.
attributeSet the value of an attribute of this node.
getTextReturns the value of a Text element.
setTextSets the value of a Text element.
Functions
childrenCount the number of child nodes.
childrenCount the number of child nodes with a specific tag.
childrenCount the number of child nodes with a specific type.
childAccess a specific child of this node.
childAccess a specific child of this node by tag.
childAccess a specific child of this node by type.
last_childAccess the child with the highest integer index.
appendChildAdd a child onto this node.
remove_childRemove a child from this node.
remove_childRemove a child from this node by tag.
remove_childRemove a child from this node by type.
Parent( ) as node ptr
treeBase XML class, node is a sub-class of this class.
Variables
rootUsed to access the XML document structure.
Functions
loadLoads a XML data structure from a file.
unloadUnloads a XML data structure to a file

License

Copyright © 2009, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License

Macros

FBEXT_XML_IS_WHITESPACE

#define FBEXT_XML_IS_WHITESPACE(
   c
) ((c) = &h09 or (c) = &h0a or (c) = &h0d or (c) = &h20)

returns true if character is a whitespace character.

ext.xml

Summary
Enumerations
charContains the ASCII characters that are special or must be escaped in XML.
Functions
encode_entitiesEncodes special characters in a string to their proper form.
decode_entitiesDecodes special characters in a string to their standard form.
encode_utf8Encodes a UTF-8 character to its string representation.
decode_utf8Decodes a UTF-8 character from its string representation.
Enumerations
node_type_eRepresents the different types of nodes supported.

Enumerations

char

Contains the ASCII characters that are special or must be escaped in XML.

Functions

encode_entities

declare function encode_entities(byref text as const string) as string

Encodes special characters in a string to their proper form.

Parameters

texttext to encode entities in.

Returns

string containing the properly formatted special characters.

decode_entities

declare function decode_entities(byref text as const string) as string

Decodes special characters in a string to their standard form.

Parameters

texttext to decode entities in.

Returns

string containing the unescaped characters.

encode_utf8

declare function encode_utf8(byval u as integer) as zstring ptr

Encodes a UTF-8 character to its string representation.

Parameters

uinteger representation of the desired UTF-8 character.

Returns

zstring ptr, the encoded UTF-8 character.

decode_utf8

declare function decode_utf8(byval src as zstring ptr,
byref u as integer) as integer

Decodes a UTF-8 character from its string representation.

Parameters

srczstring ptr containing the encoded UTF-8 character.
uinteger representation of the encoded UTF-8 character is returned via this parameter.

Returns

integer, the number of characters the UTF-8 character occupied while encoded.

Enumerations

node_type_e

Represents the different types of nodes supported.

Valid values are

  • element
  • text
  • comment
  • processingInstruction
  • cdata
  • declaration

node

Child XML class, branch and leaf nodes.

Supports casting to string to print out XML data of the node and its children.

Summary
Variables
tagContains this child’s tag name
Functions
node_typeAccess the type of the node.
Properties
attributeAccess the value of an attribute of the node.
attributeSet the value of an attribute of this node.
getTextReturns the value of a Text element.
setTextSets the value of a Text element.
Functions
childrenCount the number of child nodes.
childrenCount the number of child nodes with a specific tag.
childrenCount the number of child nodes with a specific type.
childAccess a specific child of this node.
childAccess a specific child of this node by tag.
childAccess a specific child of this node by type.
last_childAccess the child with the highest integer index.
appendChildAdd a child onto this node.
remove_childRemove a child from this node.
remove_childRemove a child from this node by tag.
remove_childRemove a child from this node by type.
Parent( ) as node ptr

Variables

tag

as string tag

Contains this child’s tag name

Functions

node_type

declare function nodeType() as node_type_e

Access the type of the node.

Returns

node_type_e, this node’s type.

Properties

attribute

declare property attribute(byref attribute as const string) as string

Access the value of an attribute of the node.

Parameters

attributethe name of the attribute you wish to retrieve.

Returns

string, the requested attribute’s value.

attribute

declare property attribute(byref attribute as const string,
byref new_value as const string)

Set the value of an attribute of this node.

Parameters

attributethe name of the attribute
new_valuethe value to assign to attribute

getText

declare property getText( ) as string

Returns the value of a Text element.

setText

declare property setText(byref text_ as const string)

Sets the value of a Text element.

Parameters

text_the value to assign to the Text element.

Functions

children

declare function children() as integer

Count the number of child nodes.

Returns

integer, count of children of this node.

children

declare function children(byref tag as const string) as integer

Count the number of child nodes with a specific tag.

Parameters

tagtag to limit count.

Returns

integer, count of children of this node matching the specified tag.

children

declare function children(byval node_type as node_type_e) as integer

Count the number of child nodes with a specific type.

Parameters

node_typenode type to limit count.

Returns

integer, count of children of this node matching the specified type.

child

declare function child(byval index as integer =  0) as node ptr

Access a specific child of this node.

Parameters

indexinteger index value of child.

Returns

node ptr, access with ->

child

declare function child(byref tag as const string,  
byval index as integer =  0) as node ptr

Access a specific child of this node by tag.

Parameters

tagtag to limit index to.
indexinteger index value of child.

Returns

node ptr, access with ->

child

declare function child(byval node_type as node_type_e,  
byval index as integer =  0) as node ptr

Access a specific child of this node by type.

Parameters

node_typenode type to limit index to.
indexinteger index value of child.

Returns

node ptr, access with ->

last_child

Access the child with the highest integer index.

Returns

node ptr, access with ->

appendChild

declare function appendChild(
   byref tag as const string,  
   byval node_type as node_type_e =  element
) as node ptr

Add a child onto this node.

Parameters

tagtag to give new child.
node_typeoptional type of node to create, defaults to element.

Returns

node ptr of the new child, not needed for normal usage.

remove_child

Remove a child from this node.

Parameters

indexinteger index of node to remove.

remove_child

Remove a child from this node by tag.

Parameters

tagtag of node to limit index to.
indexinteger index of node to remove.

remove_child

Remove a child from this node by type.

Parameters

node_typenode type to limit index to.
indexinteger index of node to remove.

Parent( ) as node ptr

tree

Base XML class, node is a sub-class of this class.

Supports casting to a string to print all XML data.

Summary
Variables
rootUsed to access the XML document structure.
Functions
loadLoads a XML data structure from a file.
unloadUnloads a XML data structure to a file

Variables

root

as node ptr root

Used to access the XML document structure.

Functions

load

declare function load(byref xmlfile as const string) as integer

Loads a XML data structure from a file.

Parameters

xmlfilethe file to load

Returns

integer, value representing success or failure.

unload

declare function unload(byref xmlfile as const string) as integer

Unloads a XML data structure to a file

this does not destroy the structure

Parameters

xmlfilethe file to unload to

Returns

integer, value representing success or failure.

#define FBEXT_XML_IS_WHITESPACE(
   c
) ((c) = &h09 or (c) = &h0a or (c) = &h0d or (c) = &h20)
returns true if character is a whitespace character.
declare function encode_entities(byref text as const string) as string
Encodes special characters in a string to their proper form.
declare function decode_entities(byref text as const string) as string
Decodes special characters in a string to their standard form.
declare function encode_utf8(byval u as integer) as zstring ptr
Encodes a UTF-8 character to its string representation.
declare function decode_utf8(byval src as zstring ptr,
byref u as integer) as integer
Decodes a UTF-8 character from its string representation.
as string tag
Contains this child’s tag name
declare function nodeType() as node_type_e
Access the type of the node.
declare property attribute(byref attribute as const string) as string
Access the value of an attribute of the node.
declare property getText( ) as string
Returns the value of a Text element.
declare property setText(byref text_ as const string)
Sets the value of a Text element.
declare function children() as integer
Count the number of child nodes.
declare function child(byval index as integer =  0) as node ptr
Access a specific child of this node.
declare function appendChild(
   byref tag as const string,  
   byval node_type as node_type_e =  element
) as node ptr
Add a child onto this node.
as node ptr root
Used to access the XML document structure.
declare function load(byref xmlfile as const string) as integer
Loads a XML data structure from a file.
declare function unload(byref xmlfile as const string) as integer
Unloads a XML data structure to a file