Login   Register  
PHP Classes
elePHPant
Icontem

File: documentation.xml

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of khalid al-kary  >  Kxparse  >  documentation.xml  >  Download  
File: documentation.xml
Role: Documentation
Content type: text/plain
Description: the Docs XML file
Class: Kxparse
A very light XML parser!
Author: By
Last change: Documentation update to reflect the changes in version 1.2
Date: 11 years ago
Size: 26,595 bytes
 

Contents

Class file image Download
<?xml version="1.0"?>
<documentation status="function names are guaranteed to stay as they are now, it's safe to write a big work with it" date="November the 1st 2002">
<basic title="Basics">
<base title="Things you should already know">
First of all, you must have studied the following topics to continue:

The &lt;a href="http://www.php.net"&gt;PHP&lt;/a&gt; Scripting Language
XML (extensible markup language)

If you don't know about these things yet, please &lt;font color="red"&gt;study them first&lt;/font&gt;.
</base>
<base title="The tag selection base">
in most of the API functions introduced in Kxparse you will remark a method of direct tag selection, this method allows selection of tags in the deepest trees (unlimited) with only one API function, for example:

get_attribute("enclosingtag:child:childofchild:childofchildofchild","1:2:1:4","name");

So what is that? this function told the parser to first select the root tag of the XML document with the index 1, and then to select its child named "child" with the index 2, and then the child of child named "childofchild" index 1,and then the child of child of child called "childofchildofchild" with index 4.

If we looked at the XML snippet below, this function will select the tag in bold, and then extract from it (according to the function), the attribute value written in red:

/*&ltt;?xml version="1.0"?&gtt;
&ltt;enclosingtag&gtt;
	&ltt;child&gtt;
	any value or children go here
	&ltt;/child&gtt;
	&ltt;child&gtt;
		&ltt;childofchild&gtt;
			&ltt;childofchildofchild&gtt;
			any value here
			&ltt;/childofchildofchild&gtt;
			&ltt;childofchildofchild&gtt;
			any value here
			&ltt;/childofchildofchild&gtt;
			&ltt;childofchildofchild&gtt;
			any value here
			&ltt;/childofchildofchild&gtt;
			&lt;b&gt;&ltt;childofchildofchild name="&lt;font color="red"&gt;any name man :)&lt;/font&gt;"&gtt;
			&ltt;/childofchildofchild&gtt;&lt;/b&gt;
		&ltt;/childofchild&gtt;
	&ltt;/child&gtt;
&ltt;/enclosingtag&gtt;

There's one more rule for ease of use, you can remove the the index and write "-1" instead, this refers to the last tag of the name matching it in the tag name string, for example:

because the example above introduced "4" in the last selection, and 4 is same as the last tag in the snippet so the following code will give the same value marked in the snippet:

get_attribute("enclosingtag:child:childofchild:childofchildofchild","1:2:1:&lt;font color="red"&gt;-1&lt;/font&gt;","name");

Note: When we get to API documentation, you will be able to see the difference between normal strings and these colon separated strings like that:

the tag name colon-spearated list will be called: colonedtagname
the tag index colon-separated list will be called: colonedtagindex

&lt;font color="red"&gt;Note: Since Kxparse 1.0 it is safe to write more than one "-1" for example(not with the snippet above): &lt;/font&gt;

get_attribute("enclosingtag:child:childofchild:childofchildofchild","&lt;font color="red"&gt;-1:-1:-1:-1&lt;/font&gt;","name");
</base>
<base title="Name Spaces support">
in Kxparse 1.0 it's possible to select a tag name that has a name space in it, just surround the tag name with braces for example:

&lt;code&gt;get_tag_text("atag:anothertag:(xsl:apply-templates)","1:1:1","name");&lt;/code&gt;
</base>
</basic>
<api title="API Documentation">
<function name="kxparse" text="Class constructor">
&lt;code&gt;kxparse(string file)&lt;/code&gt;

This is the constructor through which you can instantiate Kxparse, it takes only one argument which is the XML file you want the parser to work on, the parser then loads the XML file in the object variable &lt;code&gt;xml&lt;/code&gt;.

Note: The function inherits its functionality from the PHP function fopen, everything that applies to that function applies here as well, for example, you can open remote files on HTTP/FTP servers, by specifying a valid URL in the &lt;code&gt;file&lt;/code&gt; argument.
</function>
<function name="get_attribute" text="Get the value of an attribute of a tag in the XML tree">
&lt;code&gt;string get_attribute(string colonedtagname, string colonedtagindex, string attribute)&lt;/code&gt;

This function simply gets the value of the &lt;code&gt;attribute&lt;/code&gt; from the tag selected using the &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt;

The &lt;code&gt;colonedtagname&lt;/code&gt; is a colon-separated list of the tag tree, and the &lt;code&gt;colonedtagindex&lt;/code&gt; is a colon-separated list of the tree indeces.

Example:
&lt;code&gt;get_attribute("myroot:firstlevel","1:3","name")&lt;/code&gt;

Will select the tag in bold and the attribute value in red of the XML snippet below:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel name="&lt;font color="red"&gt;my name&lt;/font&gt;"&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;
</function>
<function name="get_tag_text" text="Get the text of a tag available in the XML tree">
&lt;code&gt;string get_tag_text(string colonedtagname, string colonedtagindex)&lt;/code&gt;

This function will get the text enclosed within the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt;.

The &lt;code&gt;colonedtagname&lt;/code&gt; is a colon-separated list of the tag tree, and the &lt;code&gt;colonedtagindex&lt;/code&gt; is a colon-separated list of the tree indeces.

Example:
&lt;code&gt;get_tag_text("myroot:firstlevel","1:3")&lt;/code&gt;

Will select the tag in bold and return the text in red of the XML snippet below:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel&gtt;
	&lt;font color="red"&gt;the text selected&lt;/font&gt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;
</function>
<function name="set_attribute" text="Set the value of an attribute of a tag in the XML tree">
&lt;code&gt;void set_attribute(string colonedtagname, string colonedtagindex, string attribute, string value)&lt;/code&gt;

This function either adds a new attribute to the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt; and assigns the given value to it, or(if the attribute was already found) changes the value of an already available attribute in that tag to the given value.

The &lt;code&gt;colonedtagname&lt;/code&gt; is a colon-separated list of the tag tree, and the &lt;code&gt;colonedtagindex&lt;/code&gt; is a colon-separated list of the tree indeces.

Example:
&lt;code&gt;set_attribute("myroot:firstlevel","1:3","name","Kxparse is useful")&lt;/code&gt;

Before excution of the above code(the tag concerned with the change is in bold):

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;

After Excution of the code, the tag in bold and the change in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel &lt;font color="red"&gt;name="Kxparse is useful"&lt;/font&gt;&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;
</function>
<function name="count_tag" text="Counts the number of occurences of a particular tag">
&lt;code&gt;integer count_tag(string colonedtagname, string colonedtagindex)&lt;/code&gt;

This function is used to count the number of tags in a particular level of the XML file.

&lt;code&gt;colonedtagname&lt;/code&gt; is a colon-separated list of the tags, the last tag of them is the tag which you want to count, and the tag before the last is the parent tag of the counted tag.

&lt;code&gt;colonedtagindex&lt;/code&gt; is a colon-separated list of the tags matching the tree inserted in &lt;code&gt;colonedtagname&lt;/code&gt;, the last index is removed and instead of it writen a question mark "?", so that the parser knows that you want to count the occurences of the tag matching the question mark.

Example:
&lt;code&gt;count_tag("myroot:firstlevel","1:?")&lt;/code&gt;

This will return 3 and will count the tags in bold in the XML snippet below:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&lt;b&gt;&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;
</function>
<function name="remove_tag" text="Remove a tag from the XML tree">
&lt;code&gt;void remove_tag(string colonedtagname, string colonedtagindex)&lt;/code&gt;

This function removes a tag (with its children) from the XML tree, this tag is selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt;

&lt;code&gt;colonedtagindex&lt;/code&gt; is a colon-separated list of the tags matching the tree inserted in &lt;code&gt;colonedtagname&lt;/code&gt;, the last index is removed and instead of it writen a question mark "?", so that the parser knows that you want to count the occurences of the tag matching the question mark.

Example:
&lt;code&gt;remove_tag("myroot:firstlevel","1:2")&lt;/code&gt;

Before excution, the part that will be removed is in bold:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel someattr="some value"&gtt;
	this tag will be removed ofcourse
	&ltt;/firstlevel&gtt;&lt;/b&gt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;

After excution of the above example:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;

</function>
<function name="create_tag" text="Create a tag in the XML tree">
&lt;code&gt;void create_tag(string colonedtagname,string colonedtagindex, string tagname)&lt;/code&gt;

This function inserts a tag in the XML tree, and appends it to the children of the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt;

&lt;code&gt;colonedtagindex&lt;/code&gt; is a colon-separated list of the tags matching the tree inserted in &lt;code&gt;colonedtagname&lt;/code&gt;, the last index is removed and instead of it writen a question mark "?", so that the parser knows that you want to count the occurences of the tag matching the question mark.

Example:
&lt;code&gt;create_tag("myroot:firstlevel","1:2","secondlevel")&lt;/code&gt;

Before excution, the parent under which the tag will be inserted is in bold:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel someattr="some value"&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;

After excution, the tag inserted is marked in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel someattr="some value"&gtt;
	&lt;font color="red"&gt;&ltt;secondlevel&gtt;
	&ltt;/secondlevel&gtt;&lt;/font&gt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;
</function>
<function name="save" text="Save the current XML content">
void save(string file)

This function simply saves the current XML content to &lt;code&gt;file&lt;/code&gt;

If the file is already available the function will overwrite it.

Note: as fopen doesn't allow writing on remote servers, so this function is only able to save to the local web tree or physical path.

Example:
&lt;code&gt;save("../myfirstxml.xml")&lt;/code&gt;

</function>
<function name="xml" text="a Property that holds the current XML content">
&lt;code&gt;string xml&lt;/code&gt;

This is a property that holds the current XML content in the parser, all functions operate on it.

you can use it to modify the XML content yourself, for example, you can delete the current XML content:

&lt;code&gt;$xmlobj->xml=""&lt;/code&gt;

And then load your own XML into it

&lt;code&gt;$xmlobj->xml="&ltt;?xml version="1.0"?&gtt;&ltt;root&gtt;&ltt;/root&gtt;"

you can also use it to just print the current XML content:

&lt;code&gt;echo $xmlobj->xml&lt;/code&gt;
</function>
<function name="set_tag_text" text="Sets the text of a tag present in the XML tree">
&lt;code&gt;void set_tag_text(string colonedtagname, string colonedtagindex, string text)&lt;/code&gt;

This function is used to change the text of the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt;.

&lt;code&gt;colonedtagindex&lt;/code&gt; is a colon-separated list of the tags matching the tree inserted in &lt;code&gt;colonedtagname&lt;/code&gt;, the last index is removed and instead of it writen a question mark "?", so that the parser knows that you want to count the occurences of the tag matching the question mark.

Example:
&lt;code&gt;set_tag_text("myroot:firstlevel","1:3","The new text")&lt;/code&gt;

Before excution, the tag is in bold and the text that will be replaced is in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel someattr="some value"&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel&gtt;
	&lt;font color="red"&gt;This a bad text that will be replaced&lt;/font&gt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;

After excution, the inserted text is also in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel someattr="some value"&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel&gtt;
	&lt;font color="red"&gt;The new text&lt;/font&gt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;
</function>
<function name="set_pi" text="Sets or changes the a particular attribute of the Processing Instruction">
&lt;code&gt;void set_pi(string attribute, string value)&lt;/code&gt;

This function simply adds a new processing instruction &lt;code&gt;attribute&lt;/code&gt; with the value &lt;code&gt;value&lt;/code&gt;

If the processing instruction attribute was found the function changes its value to &lt;code&gt;value&lt;code&gt;

Example:
&lt;code&gt;set_pi("encoding","ISO-8859-1")&lt;/code&gt;

Before the change the affected area is in bold:

&lt;b&gt;&ltt;?xml version="1.0"?&gtt;&lt;/b&gt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel someattr="some value"&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;

After the change, the inserted attribute and value are in red:

&lt;b&gt;&ltt;?xml version="1.0" &lt;font color="red"&gt;encoding="ISO-8859-1"&lt;/font&gt; ?&gtt;&lt;/b&gt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel someattr="some value"&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;
</function>
<function name="load" text="Dynamically Loads a new XML file into the parser">
&lt;code&gt;void load(string filename)&lt;/code&gt;

This function erases the current XML content and then loads another XML file into the parser.

You may here -as well as the constructor- use a URL as the &lt;code&gt;filename&lt;/code&gt;

Example:
&lt;code&gt;load("http://www.mydomain.com/example.xml")&lt;/code&gt;

</function>
<function name="search_tags" text="Search for a tag in the XML tree that has a known text">
&lt;code&gt;mixed search_tags(string colonedtagname, string colonedtagindex, string matchtext)&lt;/code&gt;

This function searches for a tag in the XML tree which has text matching &lt;code&gt;matchtext&lt;/code&gt;

The function searches in collection of tags indiciated by the index which has the "?" instead of the index number, and with the name corresponding to the ? in &lt;code&gt;colonedtagname&lt;/code&gt;

If the function finds results, it returns an array carrying the indeces of the matching tags, if no tags matched it returns false

Example:
&lt;code&gt;search_tags("myroot:firstlevel","1:?","the new text")&lt;/code&gt;

The tags that will be searched are in bold and the matching tags are in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&lt;b&gt;&lt;font color="red"&gt;&ltt;firstlevel&gtt;
	the new text
	&ltt;/firstlevel&gtt;&lt;/font&gt;
	&ltt;firstlevel&gtt;
	something different from "the new text"
	&ltt;/firstlevel&gtt;
	&lt;font color="red"&gt;&ltt;firstlevel&gtt;
	the new text
	&ltt;/firstlevel&gtt;&lt;/b&gt;&lt;/font&gt;
&ltt;/myroot&gtt;
</function>
<function name="isearch_tags" text="Case-insensitive search for a tag in the XML tree that has a known text">
Identical to search_tags in everything, the only difference is that it's case-insensitive
</function>
<function name="search_attributes" text="Search for a tag in the XML tree that has a particular attribute value">
&lt;code&gt;mixed search_attributes(string colonedtagname, string colonedtagindex, string attributename, string attributevalue)&lt;/code&gt;

The function searches for a tag in the XML tree whose attribute named &lt;code&gt;attributename&lt;/code&gt; has the value &lt;code&gt;attributevalue&lt;/code&gt;

The function searches in collection of tags indiciated by the index which has the "?" instead of the index number, and with the name corresponding to the ? in &lt;code&gt;colonedtagname&lt;/code&gt;

If the function finds results, it returns an array carrying the indeces of the matching tags, if no tags matched it returns false

Example:
&lt;code&gt;search_attributes("myroot:firstlevel","1:?","name","a good name")&lt;/code&gt;

The searched tags are in bold and the mathcing are in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&lt;b&gt;&lt;font color="red"&gt;&ltt;firstlevel name="a good name"&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel name="a good name"&gtt;
	&ltt;/firstlevel&gtt;&lt;/font&gt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
&ltt;/myroot&gtt;
</function>
<function name="isearch_attributes" text="Case-insensitive search for a tag in the XML tree that has a particular attribute value">
Identical to search_attributes in everything, the only difference is that it's case-insensitive
</function>
<function name="has_attribute" text="Checks if a tag has a particular attribute">
&lt;code&gt;boolean has_attribute(string colonedtagname, string colonedtagindex, string attributename)&lt;/code&gt;

This function checks if the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt; has an attribute named &lt;code&gt;attribute name&lt;/code&gt;

returns true in case that the attribute was found, otherwise the function returns false

Example:
with the XML snippet below, the following code will return true
&lt;code&gt;has_attribute("myroot:firstlevel","1:1","name")&lt;/code&gt;

while this one will return false:
&lt;code&gt;has_attribute("myroot:firstlevel","1:1","age")&lt;/code&gt;

The tag which both of the functions operate on is in bold:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&lt;b&gt;&ltt;firstlevel name="a good name"&gtt;&lt;/b&gt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel name="a good name"&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;
</function>
<function name="get_attributes" text="Get all the attributes of a tag with their values in an array">
&lt;code&gt;Array get_attributes(string colonedtagname, string colonedtagindex)&lt;/code&gt;

This function returns an array of (attribute name->attribute value) pairs of the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt;

Example:
&lt;code&gt;get_attributes("myroot:firstlevel","1:2")&lt;/code&gt;

on the XML snippet below, the tag that will be operated on is in bold:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel name="a good name" age="no age" gender="no gender"&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;

Will return:

Array
(
	[name] => a good name	
	[age] => no age
	[gender] => no gender
)
</function>
<function name="set_ns" text="disables or enables namespaces support">
&lt;code&gt;void set_ns(boolean to)&lt;/code&gt;

Namespaces support is enabled by default, but if you are sure that your XML document won't contain namespaces, so it's better to disable namespaces support for faster parsing.

This function enables you to do this because it sets namespaces support according to the boolean variable &lt;code&gt;to&lt;/code&gt;

Note: namespaces support doesn't change when you use the function &lt;code&gt;load&lt;/code&gt; to load a new XML file, you must manually edit it if you want to.

Note: expectedly disabling namespaces support makes the function &lt;code&gt;create_tag&lt;/code&gt; return an error message when you try to create a tag with a namespace in it.

&lt;font color="red"&gt;Note: trying to retrieve a tag with a namespace in it while the support is disabled will in most cases return an error message, but in other -few- cases it may &lt;b&gt;make unexpected changes to the file&lt;/b&gt;&lt;/font&gt;

Refer to the &lt;a href="docs.php?place=base"&gt;Basics section&lt;/a&gt; for more info about namespaces support

Example:
&lt;code&gt;set_ns(false)&lt;/code&gt;

This disables namespaces support
</function>
<function name="set_attributes" text="Set a group of attributes for a tag using an array">
&lt;code&gt;void set_attributes(string colonedtagname, string colonedtagindex, string[][] arr)&lt;/code&gt;

This function gets an array &lt;code&gt;arr&lt;/code&gt; (attribute name -> attribute value) and sets attributes for the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt; according to it.

It's good for integration with &lt;code&gt;get_attributes&lt;/code&gt;, to copy the whole attributes of a tag typically, or after edition to another tag.

Example:
consider the following array named &lt;code&gt;atts&lt;/code&gt;:
&lt;code&gt;
print_r($atts);

produces the following:

Array
(
	[name]=> no name
	[age]=> no age
}
&lt;/code&gt;

Using it with this function like this:
&lt;code&gt;set_attributes("myroot:firstlevel","1:3",$atts)&lt;/code&gt;

Before edition the selected tag is in bold:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;

After edition the affected tag is in bold and the inserted attributes are in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel &lt;font color="red"&gt;name="no name" age="no age"&lt;/font&gt;&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;
</function>
<function name="set_CD" text="Enables/disables CDATA sections support">
&lt;code&gt;void set_CD(boolean to)&lt;/code&gt;

CDATA sections support is enabled by default, but it was found that it greatly affects the parser speed, so if you are sure that your XML document will not contain CDATA sections, it's extremely recommended to disable CDATA sections support.

This function enables you to do that, according to the argument &lt;code&gt;to&lt;/code&gt; -- true enables and false disables.

The function then does all the internal changes required.

Example:
&lt;code&gt;set_CD(false)&lt;/code&gt;

disables CDATA sections support.
</function>
<function name="create_CD" text="Makes a CDATA section from a given text">
&lt;code&gt;string create_CD(string text)&lt;/code&gt;

This is an auxillary function that automatically creates a CDATA section out of the given text.
honestly it does two things:

-- It checks for CDATA tags inside the given text, if found the function gives an error message
-- Concats the start and end of the CDATA section tag to the given string

You can then use this function with &lt;code&gt;set_tag_text&lt;/code&gt;.

Example:
&lt;code&gt;create_CD("no one but no one can catch &ltt;![CDATA[ elmagnifico ]]&gtt;")&lt;/code&gt;

This will kill your script and write:

Error: Kxparse: create_CD: A CDATA section cannot contain an opening or closing symbol of CDATA

Because simply the given text contained a CDATA tag.
</function>
<function name="to_internal_close" text="turns an empty tag into an internally-closed tag">
&lt;code&gt;void to_internal_close(string colonedtagname, string colonedtagindex)&lt;/code&gt;

This function turns the tag selected by &lt;code&gt;colonedtagname&lt;/code&gt; and &lt;code&gt;colonedtagindex&lt;/code&gt; into an internally closed tag.

If the tag contained text it's not turned, not to lose data.

If the tag is already internally closed, the function does nothing.

Note: The function preserves the attributes of the tag.

Example:
to_internal_close("root:firstlevel","1:2")

Before execution, The affected tag is in bold:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&ltt;firstlevel name="good name"&gtt;
	&ltt;/firstlevel&gtt;&lt;/b&gt;
	&ltt;firstlevel name="no name" age="no age"&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;

After excution the resulting tag is in red:

&ltt;?xml version="1.0"?&gtt;
&ltt;myroot&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
	&lt;b&gt;&lt;font color="red"&gt;&ltt;firstlevel name="good name"/&gtt;&lt;/font&gt;&lt;/b&gt;
	&ltt;firstlevel name="no name" age="no age"&gtt;
	&ltt;/firstlevel&gtt;
	&ltt;firstlevel&gtt;
	&ltt;/firstlevel&gtt;
&ltt;/myroot&gtt;
</function>
</api>
</documentation>