This class is used for building and rendering an XML tag.
This class is the base class for the HTMLTagClass.
This is part of the phphtmllib libraries released under the LGPL license.
Located in /XMLTagClass.inc (line 35)
Container | --XMLTagClass
Class | Description |
---|---|
HTMLTagClass | Base class for all HTML Tag classes. |
SVGTagClass | This overrides the WMLTagClass to define some methods that set some commonly used SVG tag attributes. |
WMLTagClass | Base class for all WML Tag classes. |
XMLtag | xml tag class |
The constructor
- function XMLTagClass($name, $attributes=array() ) {
- $this->set_tag_name( $name );
- $this->set_tag_attributes( $attributes );
- $num_args = func_num_args();
- for ($i=2;$i<$num_args;$i++) {
- $this->add(func_get_arg($i));
- }
- $this->_set_flags();
- }
This returns the tag declared for this class.
This should be used in favor of accessing the $this->_tag directly.
- function get_tag() {
- //for compatibility only
- return $this->get_tag_name();
- }
This method allows you to get the value for a tag attribute.
This method gets the name of the tag
- function get_tag_name() {
- return $this->_tag;
- }
This function is responsible for rendering the tag and its contents
- function render( $indent_level=0 ) {
- //try and guess the indentation flags
- //based on the data
- $this->_prepare_flags();
- //return $xml;
- return $this->_render_open_tag( $indent_level ) .
- $this->_render_content( $indent_level ) .
- $this->_render_close_tag( $indent_level );
- }
clear all attributes and start with new attributes
- function reset_attributes( $attributes=array() ) {
- $this->_attributes = array();
- $this->set_tag_attributes( $attributes );
- }
This method turns on the automatic wrapping of the tag's content inside the CDATA wrapper for XML
- function set_cdata_flag($flag) {
- if ($flag) {
- $this->_flags |= _CDATACONTENTWRAP;
- $this->set_collapse(TRUE);
- } else{
- $this->_flags &= ~_CDATACONTENTWRAP;
- }
- }
This function turns on the collapse flag
- function set_collapse($collapse=TRUE, $indent=TRUE) {
- if ($collapse) {
- $this->_flags |= _COLLAPSE;
- } else {
- $this->_flags &= ~_COLLAPSE;
- }
- $this->set_newline_after_opentag(FALSE);
- $this->set_indent_flag($indent);
- if ($indent) {
- $this->set_newline_after_closetag(TRUE);
- } else {
- $this->set_newline_after_closetag(FALSE);
- }
- }
set the newline_after_content flag
- function set_newline_after_closetag( $flag ) {
- if ($flag) {
- $this->_flags |= _NEWLINEAFTERCLOSETAG;
- } else{
- $this->_flags &= ~_NEWLINEAFTERCLOSETAG;
- }
- }
set the newline_after_opentag flag
- function set_newline_after_opentag( $flag ) {
- if ($flag) {
- $this->_flags |= _NEWLINEAFTEROPENTAG;
- } else{
- $this->_flags &= ~_NEWLINEAFTEROPENTAG;
- }
- }
add a single attribute (name="value")
- function set_tag_attribute( $name, $value=NULL ) {
- if (!$value) {
- $value = $name;
- }
- $this->_attributes[$name] = $value;
- }
add multiple attributes (name="value")
- function set_tag_attributes( $attributes=array() ) {
- $this->_attributes = array_merge($this->_attributes, $attributes);
- }
This method sets the name of the tag
- function set_tag_name( $name ) {
- $this->_tag = $name;
- }
This method is used to set the bitmask flags for this tag. It tells the class how to render the tag.
Inherited From Container
Container::Container()
Container::add()
Container::add_reference()
Container::count_content()
Container::get_element()
Container::get_indent_flag()
Container::push()
Container::push_reference()
Container::render()
Container::reset_content()
Container::set_collapse()
Container::set_indent_flag()
Documentation generated on Thu, 1 Sep 2005 17:06:40 -0700 by phpDocumentor 1.3.0RC3