Class \Prado\Xml\TXmlDocument
TXmlDocument class.
TXmlDocument represents a DOM representation of an XML file. Besides all properties and methods inherited from TXmlElement, you can load an XML file or string by loadFromFile or loadFromString. You can also get the version and encoding of the XML document by the Version and Encoding properties.
To construct an XML string, you may do the following:
$doc=new TXmlDocument('1.0','utf-8');
$doc->TagName='Root';
$proc=new TXmlElement('Proc');
$proc->setAttribute('Name','xxxx');
$doc->Elements[]=$proc;
$query=new TXmlElement('Query');
$query->setAttribute('ID','xxxx');
$proc->Elements[]=$query;
$attr=new TXmlElement('Attr');
$attr->setAttribute('Name','aaa');
$attr->Value='1';
$query->Elements[]=$attr;
$attr=new TXmlElement('Attr');
$attr->setAttribute('Name','bbb');
$attr->Value='1';
$query->Elements[]=$attr;
The above code represents the following XML string:
<?xml version="1.0" encoding="utf-8"?>
<Root>
<Proc Name="xxxx">
<Query ID="xxxx">
<Attr Name="aaa">1</Attr>
<Attr Name="bbb">1</Attr>
</Query>
</Proc>
</Root>
Class hierarchy
Author: Qiang Xue <qiang.xue@gmail.com>Since: 3.0
public
|
|
public
|
__toString() : string
Magic-method override. Called whenever this document is used as a string.
or
|
public
|
|
public
|
|
public
|
|
public
|
loadFromString(string $string) : bool
Loads and parses an XML string.
The version and encoding will be determined based on the parsing result. |
public
|
|
public
|
|
public
|
|
public
|
|
protected
|
\Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |