4 * XML Parser: this class defines an XML Tag
\r
13 private $tagAttrib = array();
\r
16 private $tagState; // True or false ;
\r
17 //private $tagState; // 1=complete, 2=open, 3=cdata, 4=close
\r
20 * Constructor: creates a XML tag object
\r
22 * @param String $theTagName
\r
23 * @param String $theTagType
\r
24 * @param String $theTagLevel
\r
25 * @param String $theTagValue
\r
26 * @param Array $theTagAtrib
\r
28 function __construct($theTagName,$theTagType,$theTagLevel,$theTagValue,$theTagAtrib)
\r
30 // Constructor without attributes
\r
31 //function __construct($theTagName,$theTagType,$theTagLevel,$theTagValue)
\r
33 $this->tagName = $theTagName;
\r
34 $this->tagType = $theTagType;
\r
35 $this->tagLevel = $theTagLevel;
\r
36 $this->tagValue = $theTagValue;
\r
37 $this->tagAttrib = $theTagAtrib;
\r
39 } // __construct() end
\r
41 public function getTagValue()
\r
43 return $this->tagValue;
\r
46 public function getTagAttribute($attribName)
\r
48 if (isset($this->tagAttrib[$attribName]))
\r
50 return $this->tagAttrib[$attribName];
\r
58 * Adds a value to the xml tagValue
\r
60 * @param String $theTagValueAdded The value to be added
\r
62 public function addToTagValue($theTagValueAdded)
\r
64 $this->tagValue .= $theTagValueAdded;
\r
68 * Adds a child xml tag as a value to other parent tag value.
\r
70 * @param String $theTagAdded The tag yo be
\r
71 * @param String $theTagState
\r
73 public function addChildTagAsValue($theTagAdded,$theTagState,$theTagValue)
\r
77 if (($theTagAdded=='BR') && ($theTagState=='complete'))
\r
79 $this->tagValue .= '<BR/>'.$theTagValue;
\r
82 // open and close Bold tag
\r
83 if (($theTagAdded=='B') && ($theTagState=='complete'))
\r
85 $this->tagValue .= '<b>'.$theTagValue.'</b>';
\r
88 // open and close Italics tag
\r
89 if (($theTagAdded=='I') && ($theTagState=='complete'))
\r
91 $this->tagValue .= '<i>'.$theTagValue.'</i>';
\r
94 if (($theTagAdded=='U') && ($theTagState=='complete'))
\r
96 $this->tagValue .= '<u>'.$theTagValue.'</u>';
\r
99 } // end addChildTagAsValue
\r
103 * Adds an attribute and value to the XML tag
\r
105 * @param String $attName
\r
106 * @param String $attValue
\r
108 public function addAttribute($attName,$attValue)
\r
110 $this->tagAttrib[$attName] = $attValue;
\r
112 } // end addAttribute()
\r
115 * Set the state of the XML tag
\r
117 * @param Boolean $theState True or False
\r
119 public function setTagState($theState)
\r
121 $this->tagState = $theState;
\r
123 } // end setTagState()
\r
126 * Print all values of the XML tag as a String
\r
128 public function toString()
\r
130 // check if the tag is ready to show
\r
131 if ($this->tagState==true)
\r
133 echo "<br><br><b>Tag Name: </b>". $this->tagName;
\r
134 echo "<br><b>Tag Type: </b>". $this->tagType;
\r
135 echo "<br><b>Tag Level: </b>". $this->tagLevel;
\r
136 echo "<br><b>Tag Value: </b>". $this->tagValue;
\r
138 // print data if the tag has attributes
\r
139 if (count($this->tagAttrib!=0))
\r
141 echo '<br/><b>Tag Attributes: </b>';
\r
143 // Display all tag attributes; name and value
\r
144 foreach ($this->tagAttrib as $attribName => $attribValue)
\r
146 echo '<br/>------'.$attribName.' = '.$attribValue;
\r
150 echo '<br/>NO Attributes found.';
\r
151 } //end if attributes
\r
153 // end if is tag is ready
\r
155 echo '<br/><br/> --- ops!! The XML tag is not ready .... Showing NO data';
\r
156 } // end if XML tag is ready
\r
161 } // end class XmlParse
\r