PHP Class Prado\Xml\TXmlDocument
TXmlDocument represents a DOM representation of an XML file.
Besides all properties and methods inherited from {@link TXmlElement},
you can load an XML file or string by {@link loadFromFile} or {@link 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:
1
1
Afficher le fichier
Open project: pradosoft/prado
Class Usage Examples
Méthodes publiques
Méthodes protégées
Méthode |
Description |
|
buildElement ( $node ) : TXmlElement |
Recursively converts DOM XML nodes into TXmlElement |
|
Method Details
__construct()
public méthode
public __construct ( $version = '1.0', $encoding = '' ) |
__toString()
public méthode
$document = new TXmlDocument();
$document->TagName = 'root';
echo $document;
or
$document = new TXmlDocument();
$document->TagName = 'root';
$xml = (string)$document;
buildElement()
protected méthode
Recursively converts DOM XML nodes into TXmlElement
protected buildElement ( $node ) : TXmlElement |
Résultat |
TXmlElement |
the converted TXmlElement |
getEncoding()
public méthode
getVersion()
public méthode
loadFromFile()
public méthode
Loads and parses an XML document.
loadFromString()
public méthode
The version and encoding will be determined based on the parsing result.
saveToFile()
public méthode
Saves this XML document as an XML file.
saveToString()
public méthode
Saves this XML document as an XML string
setEncoding()
public méthode
setVersion()
public méthode