Xml Class Info:

Class Declaration:

class Xml extends XmlNode

File name:
cake/libs/xml.php
Description:

Main XML class.

Parses and stores XML data, representing the root of an XML document

Class Inheritance

XmlNode Object

Package
cake
Subpackage
cake.cake.libs
Since

CakePHP v .0.10.3.1400

Properties:

Show/Hide parent properties
  • attributes array

    Attributes on this node

  • children array

    This node's children

  • name string

    Name of node

  • namespace string

    Node namespace

  • namespaces array

    Namespaces defined for this node and all child nodes

  • value string

    Value of node

addGlobalNamespace

top

Alias to Xml::addNs

Parameters:
  • $name required

  • $url optional NULL

Method defined in:
cake/libs/xml.php on line 1191
Access

public

Static

addGlobalNs

top

Adds a namespace to any XML documents generated or parsed

Parameters:
  • string $name required

    The namespace name

  • string $url optional NULL

    The namespace URI; can be empty if in the default namespace map

Method defined in:
cake/libs/xml.php on line 1153
Return

boolean False if no URL is specified, and the namespace does not exist default namespace map, otherwise true

Access

public

Static

addNamespace

top

Adds a namespace to the current document

Parameters:
  • string $prefix required

    The namespace prefix

  • string $url required

    The namespace DTD URL

Method defined in:
cake/libs/xml.php on line 1063
Return

void

append

top

Append given node as a child.

Parameters:
  • object $child required

    XmlNode with appended child

  • array $options optional array ( )

    XML generator options for objects and arrays

Method defined in:
cake/libs/xml.php on line 397
Return

object A reference to the appended child node

Access

public

cakeError

top

Used to report user friendly errors. If there is a file app/error.php or app/app_error.php this file will be loaded error.php is the AppError class it should extend ErrorHandler class.

Parameters:
  • string $method required

    Method to be called in the error class (AppError or ErrorHandler classes)

  • array $messages optional array ( )

    Message that is to be displayed by the error class

Method defined in:
cake/libs/object.php on line 187
Return

error message

Access

public

child

top

Returns child node with given ID.

Parameters:
  • string $id required

    Name of child node

Method defined in:
cake/libs/xml.php on line 481
Return

object Child XmlNode

Access

public

children

top

Gets a list of childnodes with the given tag name.

Parameters:
  • string $name required

    Tag name of child nodes

Method defined in:
cake/libs/xml.php on line 507
Return

array An array of XmlNodes with the given tag name

Access

public

cloneNode

top

Returns a copy of self.

Method defined in:
cake/libs/xml.php on line 373
Return

object Cloned instance

Access

public

compare

top

Compares $node to this XmlNode object

Parameters:
  • $node required

Method defined in:
cake/libs/xml.php on line 384
Return

boolean True if the nodes match, false otherwise

Access

public

compose

top

Returns a string representation of the XML object

Parameters:
  • mixed $options optional array ( )

    If boolean: whether to include the XML header with the document (defaults to true); if an array, overrides the default XML generation options

Method defined in:
cake/libs/xml.php on line 991
Return

string XML data

Access

public

Deprecated

See

Xml::toString()

__construct

top

Constructor. Sets up the XML parser with options, gives it this object as its XML object, and sets some variables.

Options

- 'root': The name of the root element, defaults to '#document' - 'version': The XML version, defaults to '1.0' - 'encoding': Document encoding, defaults to 'UTF-8' - 'namespaces': An array of namespaces (as strings) used in this document - 'format': Specifies the format this document converts to when parsed or rendered out as text, either 'attributes' or 'tags', defaults to 'attributes' - 'tags': An array specifying any tag-specific formatting options, indexed by tag name. See XmlNode::normalize(). - 'slug': A boolean to indicate whether or not you want the string version of the XML document to have its tags run through Inflector::slug(). Defaults to true
Parameters:
  • mixed $input optional NULL

    The content with which this XML document should be initialized. Can be a string, array or object. If a string is specified, it may be a literal XML document, or a URL or file path to read from.

  • array $options optional array ( )

    Options to set up with, for valid options see above:

Method defined in:
cake/libs/xml.php on line 864

createElement

top

Creates an XmlElement object that can be appended to this document or a node in it

Parameters:
  • string $name optional NULL

    Element name

  • string $value optional NULL

    Element value

  • array $attributes optional array ( )

    Element attributes

  • string $namespace optional false

    Node namespace

Method defined in:
cake/libs/xml.php on line 169
Return

object XmlElement

createNode

top

Creates an XmlNode object that can be appended to this document or a node in it

Parameters:
  • string $name optional NULL

    Node name

  • string $value optional NULL

    Node value

  • string $namespace optional false

    Node namespace

Method defined in:
cake/libs/xml.php on line 154
Return

object XmlNode

createTextNode

top

Creates an XmlTextNode object that can be appended to this document or a node in it

Parameters:
  • string $value optional NULL

    Node value

Method defined in:
cake/libs/xml.php on line 181
Return

object XmlTextNode

dispatchMethod

top

Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array

Parameters:
  • string $method required

    Name of the method to call

  • array $params optional array ( )

    Parameter list to use when calling $method

Method defined in:
cake/libs/object.php on line 107
Return

mixed Returns the result of the method call

Access

public

document

top

Returns the XML document to which this node belongs

Method defined in:
cake/libs/xml.php on line 574
Return

object Parent XML object

Access

public

error

top

If debug mode is on, this method echoes an error message.

Parameters:
  • string $msg required

    Error message

  • integer $code optional 0

    Error code

  • integer $line optional 0

    Line in file

Method defined in:
cake/libs/xml.php on line 1003
Access

public

first

top

Returns first child node, or null if empty.

Method defined in:
cake/libs/xml.php on line 450
Return

object First XmlNode

Access

public

getError

top

Returns a string with a textual description of the error code, or FALSE if no description was found.

Parameters:
  • integer $code required

    Error code

Method defined in:
cake/libs/xml.php on line 1016
Return

string Error message

Access

public

hasChildren

top

Returns true if this structure has child nodes.

Method defined in:
cake/libs/xml.php on line 591
Return

bool

Access

public

header

top

Return a header used on the first line of the xml file

Parameters:
  • mixed $attrib optional array ( )

    attributes of the header element

Method defined in:
cake/libs/xml.php on line 1120
Return

string formated header

_killParent

top

Debug method. Deletes the parent. Also deletes this node's children, if given the $recursive parameter.

Parameters:
  • boolean $recursive optional true

    Recursively delete elements.

Method defined in:
cake/libs/xml.php on line 764
Access

protected

last

top

Returns last child node, or null if empty.

Method defined in:
cake/libs/xml.php on line 465
Return

object Last XmlNode

Access

public

load

top

Initialize XML object from a given XML string. Returns false on error.

Parameters:
  • string $input required

    XML string, a path to a file, or an HTTP resource to load

Method defined in:
cake/libs/xml.php on line 900
Return

boolean Success

Access

public

log

top

Convience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.

Parameters:
  • string $msg required

    Log message

  • integer $type optional 2

    Error type constant. Defined in app/config/core.php.

Method defined in:
cake/libs/object.php on line 148
Return

boolean Success of log write

Access

public

name

top

Returns the fully-qualified XML node name, with namespace

Method defined in:
cake/libs/xml.php on line 329
Access

public

next

top

Get next element. NOT implemented.

Method defined in:
cake/libs/xml.php on line 1029
Return

object

Access

public

nextSibling

top

Gets a reference to the next child node in the list of this node's parent.

Method defined in:
cake/libs/xml.php on line 524
Return

object A reference to the XmlNode object

Access

public

normalize

top

Gets the XML element properties from an object.

Parameters:
  • object $object required

    Object to get properties from

  • $keyName optional NULL

  • $options optional array ( )

Method defined in:
cake/libs/xml.php on line 194
Return

array Properties from object

Access

public

Object

top

A hack to support __construct() on PHP 4 Hint: descendant classes have no PHP4 class_name() constructors, so this constructor gets called first and calls the top-layer __construct() which (if present) should call parent::__construct()

Method defined in:
cake/libs/object.php on line 43
Return

Object

options

top

Sets/gets global XML options

Parameters:
  • array $options optional array ( )

Method defined in:
cake/libs/xml.php on line 1240
Return

array

Access

public

Static

parent

top

Get parent element. NOT implemented.

Method defined in:
cake/libs/xml.php on line 1051
Return

object

Access

public

parse

top

Parses and creates XML nodes from the __rawData property.

Method defined in:
cake/libs/xml.php on line 930
Return

boolean Success

Access

public

See

Xml::load()

Todo

figure out how to link attributes and namespaces

_persist

top

Checks for a persistent class file, if found file is opened and true returned If file is not found a file is created and false returned If used in other locations of the model you should choose a unique name for the persistent file There are many uses for this method, see manual for examples

Parameters:
  • string $name required

    name of the class to persist

  • $return required

  • string $object required

    the object to persist

  • $type optional NULL

Method defined in:
cake/libs/object.php on line 218
Return

boolean Success

Access

protected

Todo

add examples to manual

previous

top

Get previous element. NOT implemented.

Method defined in:
cake/libs/xml.php on line 1040
Return

object

Access

public

previousSibling

top

Gets a reference to the previous child node in the list of this node's parent.

Method defined in:
cake/libs/xml.php on line 544
Return

object A reference to the XmlNode object

Access

public

removeGlobalNamespace

top

Alias to Xml::removeNs

Parameters:
  • $name required

Method defined in:
cake/libs/xml.php on line 1228
Access

public

Static

removeGlobalNs

top

Removes a namespace added in addNs()

Parameters:
  • string $name required

    The namespace name or URI

Method defined in:
cake/libs/xml.php on line 1202
Access

public

Static

removeNamespace

top

Removes a namespace to the current document

Parameters:
  • string $prefix required

    The namespace prefix

Method defined in:
cake/libs/xml.php on line 1079
Return

void

requestAction

top

Calls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.

Parameters:
  • mixed $url required

    String or array-based url.

  • array $extra optional array ( )

    if array includes the key "return" it sets the AutoRender to true.

Method defined in:
cake/libs/object.php on line 80
Return

mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.

Access

public

resolveNamespace

top

Resolves current namespace

Parameters:
  • string $name required

  • string $url required

Method defined in:
cake/libs/xml.php on line 1169
Return

array

_savePersistent

top

You should choose a unique name for the persistent file

There are many uses for this method, see manual for examples

Parameters:
  • string $name required

    name used for object to cache

  • object $object required

    the object to persist

Method defined in:
cake/libs/object.php on line 247
Return

boolean true on save, throws error if file can not be created

Access

protected

_set

top

Allows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.

Parameters:
  • array $properties optional array ( )

    An associative array containing properties and corresponding values.

Method defined in:
cake/libs/object.php on line 166
Return

void

Access

protected

setParent

top

Sets the parent node of this XmlNode.

Parameters:
  • $parent required

Method defined in:
cake/libs/xml.php on line 344
Access

public

_stop

top

Stop execution of the current script. Wraps exit() making testing easier.

Parameters:
  • $status optional 0

Method defined in:
cake/libs/object.php on line 135
Return

void

Access

public

toArray

top

Return array representation of current object.

Parameters:
  • boolean $camelize optional true

    true will camelize child nodes, false will not alter node names

Method defined in:
cake/libs/xml.php on line 688
Return

array Array representation

Access

public

toString

top

Return string representation of current object.

Parameters:
  • $options optional array ( )

Method defined in:
cake/libs/xml.php on line 1095
Return

string String representation

Access

public