PHP XML parsing class

Source: Internet
Author: User
Tags explode strlen tag name xml parser

<?php
/*khalid XML Files Parser:: Class Kxparse, started in March 2002 by Khalid al-kary*/
Class kxparse{
var $xml;
var $cursor;
var $cursor 2;

The constructor $xmlfile is the file with want to load into the parser
function Kxparse ($xmlfile)
{
Just read the file
$file =fopen ($xmlfile, "R");

Put the text inside the "file in the" XML object variable
while (!feof ($file))
{
$this->xml.=fread ($file, 4096);
}

Close the opened file
Fclose ($file);

Set the cursor to 0 (start of document), the cursor was later used by another functions
$this->cursor=0;

Set the second CUROSR to the end of document
$this->cursor2=strlen ($this->xml);
}

/*this function gets a copy of the XML file starting from cursor and ending with Cursor2


And then counts the number of occurences of the given tag name inside


Returns an array (occurrence index-&gt; occurence position in the XML file)


This function is half of the engine that moves kxparse * *


function Track_tag_cursors ($tname)


{


Getting the copy as intended


$currxml =substr ($this-&gt;xml, $this-&gt;cursor, $this-&gt;cursor2);





Counting the number of occurences in the cut area


$occurs =substr_count ($currxml, "&lt;" $tname);





The aray that'll be returned


$tag _poses=array ();





Setting its 0-0 because indeces in Kxparse start from 1


$tag _poses[0]=0;





For each of the occurences


for ($i =1; $i &lt;= $occurs; $i + +)


{





if ($i!=1)


{


If it ' s not the ' occurence '


Start checking for the next occurence but the the previous occurences out from the string


$tag _poses[$i]=strpos ($currxml, "&lt;" $tname, $tag _poses[$i -1]+1-$this-&gt;cursor) + $this-&gt;cursor;


}


Else


{


If its the the occurence just assign its value + the cursor (because the position the XML file wholly


$tag _poses[$i]=strpos ($currxml, "&lt;" $tname) + $this-&gt;cursor;


}





}





Return that array


return $tag _poses;


}


This function strips and decodes the tag text ...


function Get_tag_text_internal ($tname)


{


Strip the tags from the returned text and the decode it


return $this-&gt;htmldecode (Strip_tags ($tname));


}

function that returns a particular attribute value ...
The tag is the tagged itself (with its start and end)
function get_attribute_internal ($tag, $attr)
{
Identifying the "character directly after the" tag name to cut it then
if (Strpos ($tag, "") <strpos ($tag, ">"))
{
$separ = "";
}
Else
{
$separ = ">";
}

Cutting of the tag name according to Separ
$tname =substr ($tag, 1,strpos ($tag, $separ)-1);

Cut the tagged starting from the white spaces after the tag name, ending with (not containing) the > of the tag start
$work =substr ($tag, strlen ($tname) +1,strpos ($tag, ">")-strlen ($tname)-1);

Get the index of the tag occurence inside $work
$index _of_attr=strpos ($work, "". $attr. " = "") +1;

Check if the attribute is found in the tag
if ($index _of_attr)
{
The attributename+ "=" "+attrbutevalue+" "" "and extract the value from between them
Calculate from where we'll cut
$index _of_value= $index _of_attr+strlen ($attr) +2;

Cut note the "Last argument for calculating" end
$work =substr ($work, $index _of_value,strpos ($work, "" ", $index _of_value)-$index _of_value);

Now return the attribute value
return $work;
}

If the attribute wasn ' t found, return false '
Else
{
return FALSE;
}
}


This function html-decodes the Var $text ...
function HtmlDecode ($text)
{
$text =str_replace ("&lt;", "<", $text);
$text =str_replace ("&gt;", ">", $text);
$text =str_replace ("&amp;", "&", $text);
$text =str_replace ("&ltt;", "&lt;", $text);
$text =str_replace ("&gtt;", "&gt;", $text);
return $text;
}

The function that saves a file to a particular location
function Save ($file)
{
Open the file and overwrite of already avilable
$my _file=fopen ($file, "WB");

$my _status holds wether the operation is okay
$my _status=fwrite ($my _file, $this->xml);

Close the file handle
Fclose ($my _file);

if ($my _status!=-1)
{
return TRUE;
}
Else
{
return FALSE;
}

}

function that gets a tag in the XML tree (with its starting and ending)


function Get_tag_in_tree ($tname, $tindex)


{


$this-&gt;get_work_space ($tname, $tindex);


Return substr ($this-&gt;xml, $this-&gt;cursor, $this-&gt;cursor2-$this-&gt;cursor);


}


function that gets the text of a tag


function Get_tag_text ($tname, $tindex)


{


$mytag = $this-&gt;get_tag_in_tree ($tname, $tindex);


return $this-&gt;get_tag_text_internal ($mytag);


}


Funtion that counts the number of occurences to a tag in the XML tree


function Count_tag ($tname, $tindex)


{


return $this-&gt;get_work_space ($tname, $tindex);


}





Functoin that gets the attribute value in a tag


function Get_attribute ($tname, $tindex, $attrname)


{


$mytag = $this-&gt;get_tag_in_tree ($tname, $tindex);


return $this-&gt;get_attribute_internal ($mytag, $attrname);


}

Very important function, half of the engine


Sets the $this-&gt;cursor and $this-&gt;cursor2 to the place where it's intended to work


function Get_work_space ($tname, $tindex)


{


Counts the number of ":" in the given Colonedtagindex


$num _of_search=substr_count ($tindex, ":");





Counts the number of ":" in the given Colonedtagname


$num _of_search_text=substr_count ($tname, ":");





Checks if they are not equal this regarded an error


if ($num _of_search!= $num _of_search_text)


{


return false;


}


Else


{


Now get the numbers in an array


$search _array=explode (":", $tindex);





and also get the corresponding tag names


$search _text_array=explode (":", $tname);





Set the cursor to 0 in order to erase former work


$this-&gt;cursor=0;





Set the Cursor2 to the "end of" the same reason


$this-&gt;cursor2=strlen ($this-&gt;xml);





Get the The Intiate


$currtname = $search _text_array[0];





Get the The "the" the "the" "the" intiate the Loop


$currtindex = $search _array[0];





The loop according to number of ":"


for ($i =0; $i &lt;count ($search _array); $i + +)


{


If it ' s not the ' the ' '


if ($i!=0)


{


So append the "latest colonedtagname to" the current tag name


$currtname = $currtname. ":" $search _text_array[$i];





and append the Latset colonedtagindex to the current tag index


$currtindex = $currtindex. ":" $search _array[$i];


}


$arr holds the number of occurences of the current tag name between the cursor and CURSOR2


$arr = $this-&gt;track_tag_cursors ($search _text_array[$i]);





The index which you want to the position of


$tem = $search _array[$i];





To support Count_tag_in_tree


When given a? It returns the number of occurences of the current tag name


if ($tem = = "?")


{


return count ($arr)-1;


}


else {





To support the Auto-last method


If the current tagged index equals "-1" so replace it with the last occurence index


if ($tem ==-1)


{


$tem =count ($arr)-1;


}





Now just set cursor one to the occurence position in the XML file accrding to $tem


$this-&gt;cursor= $arr [(int) $tem];





and set Cursor2 at the "End of" tag


$this-&gt;cursor2=strpos ($this-&gt;xml, "&lt;/". $search _text_array[$i]. " &gt; ", $this-&gt;cursor) +strlen (" &lt;/". $search _text_array[$i]." &gt; ");


}


}


}


}


The function that appends a tag to the XML tree


function Create_tag ($tname, $tindex, $ntname)


{


The intended Father tag


$this-&gt;get_work_space ($tname, $tindex);





Explode the given colonedtagname into an array


$search _text_array=explode (":", $tname);





After setting the cursors using Get_work_space


Get a cope of the returned tag


$workarea =substr ($this-&gt;xml, $this-&gt;cursor, $this-&gt;cursor2-$this-&gt;cursor);





Calculate the place where you'll put the tag, start and end


$inde = $this-&gt;cursor+strpos ($workarea, "&lt;/". $search _text_array[count ($search _text_array)-1]. " &gt; ");





Here, replace means insert because the length argument was set to 0


$this-&gt;xml=substr_replace ($this-&gt;xml, "&lt;" $ntname. " &gt;&lt;/". $ntname." &gt; ", $inde, 0);


}


The function that is sets the value of an attribute


function Set_attribute ($tname, $tindex, $attr, $value)


{


The cursors using Get_work_space


$this-&gt;get_work_space ($tname, $tindex);





Now get a copy of the XML tag between cursor and CURSOR2


$currxml =substr ($this-&gt;xml, $this-&gt;cursor, $this-&gt;cursor2-$this-&gt;cursor);





Cut the "area of" the tag on which your want to work


Starting from the tag ' &lt; ' and ending with the opening tag ' &gt; '


$work =substr ($currxml, 0,strpos ($currxml, "&gt;") +1);





If the attribute is already available


if (Strpos ($work, "". $attr. " =""))


{


Calculate the current value ' s length


$currval _length=strlen ($this-&gt;get_attribute_internal ($currxml, $attr));





Get the position of the attribute inside the tag


$my _attribute_pos=strpos ($work, "". $attr. " = "") +1;





Get the length of the attribute


$my _attribute_length=strlen ($attr);





Now replace the old value


$this-&gt;xml=substr_replace ($this-&gt;xml, $value, $this-&gt;cursor+ $my _attribute_pos+ $my _attribute_length+2,$ Currval_length);


return TRUE;


}





If the attribute wasn ' t already available '


Else


{


Check if there are other attributes in the tag


if (Strpos ($work, ""))


{


$separ = "";


}


Else


{


$separ = "&gt;";


}





Prepare the attribute


$newattr = "". $attr. = "". $value. "" ";





Insert the new attribute


$this-&gt;xml=substr_replace ($this-&gt;xml, $newattr, $this-&gt;cursor+strpos ($work, $separ), 0);


return TRUE;


}


}


The function that changes or adds the text of a tag


function Set_tag_text ($tname, $tindex, $text)


{


Firs get set the cursors using Get_work_space


$this-&gt;get_work_space ($tname, $tindex);





Explode the given colonedtagname in an array


$search _text_array=explode (":", $tname);





Get the latest name


$currtname = $search _text_array[count ($search _text_array)-1];





Calculate the start of replacement


$replace _start_index=strpos ($this-&gt;xml, "&gt;", $this-&gt;cursor) +1;





Calculate the end of replacement


$replace _end_index=strpos ($this-&gt;xml, "&lt;/". $currtname. " &gt; ", $this-&gt;cursor)-1;





Calculate the length between them


$tem = $replace _end_index-$replace _start_index+1;





And now replace


$this-&gt;xml=substr_replace ($this-&gt;xml, $text, $replace _start_index, $tem);


}


Functio that removes a tag


function Remove_tag ($tname, $tindex)


{


Set the cursors using Get_work_space


$this-&gt;get_work_space ($tname, $tindex);





Now replace with ""


$this-&gt;xml=substr_replace ($this-&gt;xml, "", $this-&gt;cursor, $this-&gt;cursor2-$this-&gt;cursor);


}

}


?&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;?xml version= "1.0"?&gt;


&lt;tryingxml testattribute= "We are Here" &gt;


&lt;firstlevel testingattribute= "No we aren ' t here" &gt;


Sometext for the


&lt;secondlevel testingattribute= "We are there" &gt;


Some text for the second level


&lt;thirdlevel testingattribute= "We aren ' t there" &gt;


Some text for the third level


&lt;/thirdlevel&gt;


&lt;thirdlevel testingattribute= "We are every where:)" &gt;


This is a test by multiple children per parent node


&lt;justachild testingattribute= "A value ofcourse" &gt;is it okay with you? Go check the script&lt;/justachild&gt;


&lt;/thirdlevel&gt;


&lt;/secondlevel&gt;


&lt;/firstlevel&gt;


&lt;/tryingxml&gt;


&nbsp;&nbsp;&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p;&nbsp;&nbsp;&nbsp; &lt;?php


including Khalid XML parser


Include_once "kxparse.php";

Create the Object
$xmlnav =new kxparse ("Nav.xml");

For ($i =1 $i &lt;= $xmlnav-&gt;count_tag ("Nav:item", "1:?"); $i + +)


{?&gt;


&lt;div class= "Navit" &gt;&lt;a href= "&lt;?php Echo $xmlnav-&gt;get_attribute (" Nav:item "," 1: ". $i," href ")?&gt;" &gt; &lt;?php Echo $xmlnav-&gt;get_tag_text ("Nav:item", "1:". $i)?&gt;&lt;/a&gt;&lt;/div&gt;


?? &gt;


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;?xml version= "1.0"?&gt;


&lt;nav&gt;


&lt;item href= "http://111cn.net/kxparse/index.php" &gt;Home&lt;/item&gt;


&lt;item href= "http://111cn.net/kxparse/news.php" &gt;News&lt;/item&gt;


&lt;item href= "http://111cn.net/kxparse/docs.php" &gt;Documentation&lt;/item&gt;


&lt;item href= "http://111cn.net/kxparse/changelog.php" &gt;change log&lt;/item&gt;


&lt;/nav&gt;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.