- Symphony 2.5.1
-
› assets
14 -
› boot
13 -
› core
23 -
› cryptography
4 -
› data-sources
0 -
› email-gateways
3 -
› events
3 -
› global
45 -
› interface
8 -
› toolkit
71 - Delegates91
- Deprecated14
Versions
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.3
- 2.7.2
- 2.7.10
- 2.7.1
- 2.7.0
- 2.6.9
- 2.6.8
- 2.6.7
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.11
- 2.6.10
- 2.6.1
- 2.6.0
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2
Options
public class XMLElement
class.xmlelement.php #14XMLElement
is a class used to simulate PHP's DOMElement
class. Each object is a representation of a HTML element
and can store it's children in an array. When an XMLElement
is generated, it is output as an XML string.
Methods
XMLElement __construct(
$name, $value, $attributes, $createHandle)
The constructor for the XMLElement
Parameters
void addClass(
$class)
A convenience method to quickly add a CSS class to this XMLElement
's
existing class attribute. If the attribute does not exist, it will
be created.
Parameters
void addProcessingInstruction(
$pi)
Adds processing instructions to this XMLElement
boolean appendChild(
$child)
Adds an XMLElement
to the children array
void appendChildArray(
$children)
A convenience method to add children to an XMLElement
quickly.
static XMLElement convertFromDOMDocument(
$root_element, $doc)
Given a DOMDocument
, this function will convert it to an XMLElement
object and return the result.
static XMLElement convertFromXMLString(
$root_element, $xml)
Given a string of XML, this function will convert it to an XMLElement
object and return the result.
Parameters
string generate(
$indent, $tab_depth, $has_parent)
This function will turn the XMLElement
into a string
representing the element as it would appear in the markup.
The result is valid XML.
Parameters
string getAttribute(
$name)
Retrieves the value of an attribute by name
array getAttributes()
Accessor for $this->_attributes
XMLElement getChild(
$position)
Retrieves a child-element by position
XMLElement getChildByName(
$name, $position)
Retrieves child-element by name and position. If no child is found,
NULL
will be returned.
array getChildren()
Accessor for $this->_children
array getChildrenByName(
$name)
Accessor to return an associative array of all $this->_children
whose's name matches the given $name
. If no children are found,
an empty array will be returned.
Returns
An associative array where the key is the $index
of the child in $this->_children
XMLElementChildrenFilter getIterator()
Accessor for $this->_children
, returning only XMLElement
children,
not text nodes.
string getName()
Accessor for $_name
integer getNumberOfChildren()
Returns the number of children this XMLElement
has.
string|XMLElement getValue()
Accessor for $_value
boolean insertChildAt(XMLElement $child)
$index,
Given a desired index, and an XMLElement
, this function will insert
the child at that index in $this->_children
shuffling all children
greater than $index
down one. If the $index
given is greater then
the number of children for this XMLElement
, the $child
will be
appended to the current $this->_children
array.
Parameters
void prependChild(XMLElement $child)
Adds an XMLElement
to the start of the children
array, this will mean it is output before any other
children when the XMLElement
is generated
boolean removeChildAt(
$index)
Given the position of the child in the $this->_children
,
this function will unset the child at that position. This function
is not reversible. This function does not alter the key's of
$this->_children
after removing a child
Parameters
Returns
True if child was successfully removed, false otherwise.
void removeClass(
$class)
A convenience method to quickly remove a CSS class from an
XMLElement
's existing class attribute. If the attribute does not
exist, this method will do nothing.
Parameters
boolean replaceChildAt(XMLElement $child)
$index,
Given the position of the child to replace, and an XMLElement
of the replacement child, this function will replace one child
with another
Parameters
void replaceValue(
$value)
This function will remove all text attributes from the XMLElement
node
and replace them with the given value.
void setAllowEmptyAttributes(
$value)
Specifies whether attributes need to have a value
or if they can be shorthand on this XMLElement
.
Parameters
void setAttribute(
$name, $value)
Sets an attribute
Parameters
void setAttributeArray(
$attributes)
A convenience method to quickly add multiple attributes to
an XMLElement
Parameters
boolean setChildren(
$children)
This function expects an array of XMLElement
that will completely
replace the contents of $this->_children
. Take care when using
this function.
Parameters
void setDTD(
$dtd)
Sets the DTD for this XMLElement
void setElementStyle(
$style)
Sets the style of the XMLElement
. Used when the
XMLElement
is being generated to determine whether
needs to be closed, is self closing or is standalone.
Parameters
void setEncoding(
$value)
Sets the encoding for this XMLElement
for when
it's generated.
void setIncludeHeader(
$value)
Sets whether this XMLElement
needs to output an
XML declaration or not. This normally is only set to
true for the parent XMLElement
, eg. 'html'.
Parameters
void setName(
$name, $createHandle)
Sets the name of this XMLElement
, ie. 'p' =>
Parameters
void setSelfClosingTag(
$value)
Sets whether this XMLElement
is self closing or not.
Parameters
void setValue(
$value)
Sets the value of the XMLElement
. Checks to see
whether the value should be prepended or appended
to the children.
Parameters
void setVersion(
$value)
Sets the version for the XML declaration of this
XMLElement
static string stripInvalidXMLCharacters(
$value)
This function strips characters that are not allowed in XML