<?php
//including khalid xml parser
include_once "kxparse.php";
//load the file into the parser: constructor(string file)
$xmltest=new kxparse(getcwd()."/testing.xml");
?><a href="testing.xml">See the XML file first</a><br>
<a href="index.php?d=t">Get Kxparse with the source of this script</a><br><br>
Note: functions editing the XML file aren't included in the example script:<br><br>
remove_tag()<br>
set_tag_text()<br>
set_attribute()<br>
create_tag()
<br><br>
<font style="font-weight:700;font-size:20px;">string get_attribute(string tagname, string index, string attributename)</font>
<br><br><font style="font-weight:600">Attribute value of the root tag:</font> <? echo $xmltest->get_attribute("tryingxml","1","testattribute");?>
<br><font style="font-weight:600">Attribute value of a first level tag:</font> <? echo $xmltest->get_attribute("tryingxml:firstlevel","1:1","testingattribute");?>
<br><font style="font-weight:600">Attribute value of a second level tag:</font> <? echo $xmltest->get_attribute("tryingxml:firstlevel:secondlevel","1:1:1","testingattribute");?>
<br><font style="font-weight:600">Attribute value of a third level tag:</font> <? echo $xmltest->get_attribute("tryingxml:firstlevel:secondlevel:thirdlevel","1:1:1:1","testingattribute");?>
<br><font style="font-weight:600">Attribute value of another third level tag:</font> <? echo $xmltest->get_attribute("tryingxml:firstlevel:secondlevel:thirdlevel","1:1:1:2","testingattribute");?>
<br><font style="font-weight:600">Attribute value of another tag under the second third level tag:</font> <? echo $xmltest->get_attribute("tryingxml:firstlevel:secondlevel:thirdlevel:justachild","1:1:1:2:1","testingattribute");?>
<br><br><font style="font-weight:700;font-size:20px;">integer count_tag(string tagname, string tagindex)</font><br>
<br><font style="font-weight:600">Note: instead of the required tag index we put a "?"</font>
<br><font style="font-weight:600">Count of firstlevel tags directly under the root:</font> <? echo $xmltest->count_tag("tryingxml:firstlevel","1:?");?>
<br><font style="font-weight:600">Count of secondlevel tags directly under firstlevel tag with index 1:</font> <? echo $xmltest->count_tag("tryingxml:firstlevel:secondlevel","1:1:?");?>
<br><font style="font-weight:600">Count of thirdlevel tags directly under secondlevel tag with index 1:</font> <? echo $xmltest->count_tag("tryingxml:firstlevel:secondlevel:thirdlevel","1:1:1:?");?>
<br><font style="font-weight:600">Count of justachild tags directly under thirdlevel tag with index 2:</font> <? echo $xmltest->count_tag("tryingxml:firstlevel:secondlevel:thirdlevel:justachild","1:1:1:2:?");?>
<br><br><font style="font-weight:700;font-size:20px;">string get_tag_text(string tagname,string tagindex)</font><br>
<br><font style="font-weight:600">Note: this function (if used with a parent tag) it returns the text of the parent and its children as well, is this a bug?</font>
<br><br><font style="font-weight:600">Text of the root tag:</font> <? echo $xmltest->get_tag_text("tryingxml","1");?>
<br><font style="font-weight:600">Text of the deepest level:</font> <? echo $xmltest->get_tag_text("tryingxml:firstlevel:secondlevel:thirdlevel:justachild","1:1:1:2:1");?>
|