Class XmlDocument

Description

Builds XML documents or loads them from a XML file or string

Examples:

  1.  /* create a simple XML tree */
  2.  $doc new XmlDocument();
  3.  $doc->DocumentElement new XmlNode('root'array('attr'=>'value'));
  4.  $child =$doc->DocumentElement->addChild(new XmlNode('child'array('attr'=>'value')));
  5.  
  6.  /* parsing a XML file */
  7.  $doc new XmlDocument();
  8.  if ($doc->parseXml('data.xml'T_BYFILE)) {
  9.    $root =$doc->getDocumentElement();
  10.    for ($i=0$i<$root->getChildrenCount()$i++)
  11.      print $root->children[$i]->getName("<br />";
  12.  }

Located in /core/xml/XmlDocument.class.php (line 63)

PHP2Go
   |
   --XmlDocument
Variable Summary
Method Summary
void addStylesheet (string $link, [bool $alternate = FALSE], [string $type = 'text/css'])
void addXmlDeclaration ([string $version = '1.0'], [string $encoding = NULL])
bool parseXml (string $xmlContent, [string $srcType = T_BYFILE], [string $srcEncoding = NULL], [string $trgEncoding = NULL])
string render ([string $lineEnd = ''], [string $indent = ''])
void setDoctype (string $uri, [string $id = NULL], [string $entries = ''])
void setNamespaceAwareness ([bool $setting = TRUE])
Variables
array $doctype = array() (line 84)

DOCTYPE settings and entries

XmlNode $DocumentElement = NULL (line 98)

Document's root node

bool $namespaceAware = FALSE (line 91)

Whether namespaces are enabled

array $styleSheet = array() (line 77)

Document stylesheets

string $xmlDecl = '' (line 70)

XML declaration

Methods
Constructor XmlDocument (line 105)

Class constructor

XmlDocument XmlDocument ()
addStylesheet (line 146)

Adds a stylesheet in the XML document

void addStylesheet (string $link, [bool $alternate = FALSE], [string $type = 'text/css'])
  • string $link: Stylesheet path
  • bool $alternate: Whether this is an alternate style
  • string $type: Content type
addXmlDeclaration (line 133)

Adds a XML declaration in the document

void addXmlDeclaration ([string $version = '1.0'], [string $encoding = NULL])
  • string $version: XML version
  • string $encoding: Encoding
getDocumentElement (line 123)

Get the document's root node

XmlNode &getDocumentElement ()
getRoot (line 114)

An alias for getDocumentElement()

XmlNode &getRoot ()
parseXml (line 187)

Builds a tree from a XML file or string

bool parseXml (string $xmlContent, [string $srcType = T_BYFILE], [string $srcEncoding = NULL], [string $trgEncoding = NULL])
  • string $xmlContent: XML contents or file path
  • string $srcType: Source type (T_BYFILE or T_BYVAR)
  • string $srcEncoding: Input encoding
  • string $trgEncoding: Output encoding
render (line 203)

Converts the XML document into a XML string

The XmlNode::render() method of each node is called recursively.

  • return: XML string
string render ([string $lineEnd = ''], [string $indent = ''])
  • string $lineEnd: Line end string
  • string $indent: Indentation string
setDoctype (line 157)

Set DOCTYPE source, path and entries

void setDoctype (string $uri, [string $id = NULL], [string $entries = ''])
  • string $uri: URI
  • string $id: Public identifier
  • string $entries: Entries
setNamespaceAwareness (line 174)

Enable/disable support for namespaces

void setNamespaceAwareness ([bool $setting = TRUE])
  • bool $setting: Flag value

Inherited Methods

Inherited From PHP2Go

PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()

Documentation generated on Sun, 07 Oct 2007 19:31:11 -0300 by phpDocumentor 1.3.2