# XMLTagClass

## This is the base tag class.

by Walter A. Boring IV
mailto:waboring@3gstech.com
© September 2005, Walter A. Boring IV
(phpHtmlLib 2.5.4)

## Description

This class is the main tag class for all XML tags that phpHtmlLib supports.

Each XML tag is broken down into it's name, attributes, content and an optional closing tag. This is also true for HTML tags.

## Creating an XML tag object.

The constructor of the XML tag object has 3 main parameters. The first parameter is the name of the tag to create. The second parameter is an array of key value pairs that make up the attributes and values for the tag. The third parameters is an infinite list of parameters that will make up the content portion of the tag.

    $test = new XMLTagClass('foo', array('test' => 1), 'some content');
    print $test->render();

Output:

    <foo test="1">some content</foo>

## Creating an XML tag object with a function.

The alternative way to create the same xml tag can be accomplised with a call to xml_tag().

    $test = xml_tag('foo', array('test' => 1), 'some content');
    print $test->render();

Output:

    <foo test="1">some content</foo>

## Closing tag

The XMLTagClass automatically determines if the closing tag is needed. If there is content in the tag, then a closing tag is built, otherwise it closes the tag in the open tag. NOTE: you can force a close tag to be required by defining a child of the XMLTagClass and setting the flag the forces the close tag.

    $test = xml_tag('foo', array('test' => 1));
    print $test->render();

Output:

    <foo test="1" />

Documentation generated on Thu, 1 Sep 2005 17:05:09 -0700 by phpDocumentor 1.3.0RC3