+++ /dev/null
-<?php\r
-// \r
-/**\r
- * XML Parser: this class defines an XML Tag \r
- */\r
-\r
-class XmlTag\r
-{\r
- private $tagName;\r
- private $tagType;\r
- private $tagLevel;\r
- private $tagValue;\r
- private $tagAttrib = array();\r
-\r
- // working on...\r
- private $tagState; // True or false ; \r
- //private $tagState; // 1=complete, 2=open, 3=cdata, 4=close\r
- \r
- /**\r
- * Constructor: creates a XML tag object\r
- *\r
- * @param String $theTagName\r
- * @param String $theTagType\r
- * @param String $theTagLevel\r
- * @param String $theTagValue\r
- * @param Array $theTagAtrib\r
- */\r
- function __construct($theTagName,$theTagType,$theTagLevel,$theTagValue,$theTagAtrib)\r
-\r
- // Constructor without attributes\r
- //function __construct($theTagName,$theTagType,$theTagLevel,$theTagValue)\r
- {\r
- $this->tagName = $theTagName;\r
- $this->tagType = $theTagType;\r
- $this->tagLevel = $theTagLevel;\r
- $this->tagValue = $theTagValue;\r
- $this->tagAttrib = $theTagAtrib;\r
- \r
- } // __construct() end\r
- \r
- public function getTagValue()\r
- {\r
- return $this->tagValue; \r
- }\r
- \r
- public function getTagAttribute($attribName)\r
- {\r
- if (isset($this->tagAttrib[$attribName]))\r
- {\r
- return $this->tagAttrib[$attribName];\r
- } else {\r
- return '';\r
- }\r
-\r
- }\r
- \r
- /**\r
- * Adds a value to the xml tagValue\r
- *\r
- * @param String $theTagValueAdded The value to be added\r
- */\r
- public function addToTagValue($theTagValueAdded)\r
- {\r
- $this->tagValue .= $theTagValueAdded;\r
- }\r
-\r
- /**\r
- * Adds a child xml tag as a value to other parent tag value. \r
- * \r
- * @param String $theTagAdded The tag yo be \r
- * @param String $theTagState\r
- */\r
- public function addChildTagAsValue($theTagAdded,$theTagState,$theTagValue)\r
- {\r
- \r
- // add <BR> Tag\r
- if (($theTagAdded=='BR') && ($theTagState=='complete'))\r
- {\r
- $this->tagValue .= '<BR/>'.$theTagValue;\r
- }\r
- \r
- // open and close Bold tag \r
- if (($theTagAdded=='B') && ($theTagState=='complete'))\r
- {\r
- $this->tagValue .= '<b>'.$theTagValue.'</b>';\r
- }\r
-\r
- // open and close Italics tag \r
- if (($theTagAdded=='I') && ($theTagState=='complete'))\r
- {\r
- $this->tagValue .= '<i>'.$theTagValue.'</i>';\r
- }\r
-\r
- if (($theTagAdded=='U') && ($theTagState=='complete'))\r
- {\r
- $this->tagValue .= '<u>'.$theTagValue.'</u>';\r
- }\r
- \r
- } // end addChildTagAsValue\r
-\r
-\r
- /**\r
- * Adds an attribute and value to the XML tag \r
- *\r
- * @param String $attName\r
- * @param String $attValue\r
- */\r
- public function addAttribute($attName,$attValue)\r
- {\r
- $this->tagAttrib[$attName] = $attValue;\r
- \r
- } // end addAttribute()\r
- \r
- /**\r
- * Set the state of the XML tag\r
- *\r
- * @param Boolean $theState True or False\r
- */\r
- public function setTagState($theState)\r
- {\r
- $this->tagState = $theState;\r
- \r
- } // end setTagState()\r
-\r
- /**\r
- * Print all values of the XML tag as a String\r
- */ \r
- public function toString()\r
- {\r
- // check if the tag is ready to show\r
- if ($this->tagState==true)\r
- {\r
- echo "<br><br><b>Tag Name: </b>". $this->tagName;\r
- echo "<br><b>Tag Type: </b>". $this->tagType;\r
- echo "<br><b>Tag Level: </b>". $this->tagLevel;\r
- echo "<br><b>Tag Value: </b>". $this->tagValue;\r
- \r
- // print data if the tag has attributes\r
- if (count($this->tagAttrib!=0))\r
- {\r
- echo '<br/><b>Tag Attributes: </b>';\r
- \r
- // Display all tag attributes; name and value\r
- foreach ($this->tagAttrib as $attribName => $attribValue)\r
- {\r
- echo '<br/>------'.$attribName.' = '.$attribValue;\r
- } // foreach end\r
- \r
- } else {\r
- echo '<br/>NO Attributes found.';\r
- } //end if attributes\r
- \r
- // end if is tag is ready\r
- } else {\r
- echo '<br/><br/> --- ops!! The XML tag is not ready .... Showing NO data';\r
- } // end if XML tag is ready\r
- \r
- }// toString() end\r
- \r
- \r
-} // end class XmlParse\r
-?>
\ No newline at end of file