[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Xml/ -> TXmlDocument.php (sommaire)

TXmlElement, TXmlDocument, TXmlElementList class file

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: TXmlDocument.php 1397 2006-09-07 07:55:53Z wei $
Poids: 496 lignes (12 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 3 classes

TXmlElement:: (16 méthodes):
  __construct()
  getParent()
  setParent()
  getTagName()
  setTagName()
  getValue()
  setValue()
  getHasElement()
  getHasAttribute()
  getAttribute()
  setAttribute()
  getElements()
  getAttributes()
  getElementByTagName()
  getElementsByTagName()
  toString()

TXmlDocument:: (10 méthodes):
  __construct()
  getVersion()
  setVersion()
  getEncoding()
  setEncoding()
  loadFromFile()
  loadFromString()
  saveToFile()
  saveToString()
  buildElement()

TXmlElementList:: (4 méthodes):
  __construct()
  getOwner()
  insertAt()
  removeAt()


Classe: TXmlElement  - X-Ref

TXmlElement class.

TXmlElement represents an XML element node.
You can obtain its tagname, attributes, text between the openning and closing
tags via the TagName, Attributes, and Value properties, respectively.
You can also retrieve its parent and child elements by Parent and Elements
properties, respectively.

TBD: xpath

__construct($tagName)   X-Ref
Constructor.

param: string tagname for this element

getParent()   X-Ref

return: TXmlElement parent element of this element

setParent($parent)   X-Ref

param: TXmlElement parent element of this element

getTagName()   X-Ref

return: string tagname of this element

setTagName($tagName)   X-Ref

param: string tagname of this element

getValue()   X-Ref

return: string text enclosed between opening and closing tag of this element

setValue($value)   X-Ref

param: string text enclosed between opening and closing tag of this element

getHasElement()   X-Ref

return: boolean true if this element has child elements

getHasAttribute()   X-Ref

return: boolean true if this element has attributes

getAttribute($name)   X-Ref

return: string the attribute specified by the name, null if no such attribute

setAttribute($name,$value)   X-Ref

param: string attribute name
param: string attribute value

getElements()   X-Ref

return: TXmlElementList list of child elements

getAttributes()   X-Ref

return: TMap list of attributes

getElementByTagName($tagName)   X-Ref

return: TXmlElement the first child element that has the specified tagname, null if not found

getElementsByTagName($tagName)   X-Ref

return: TList list of all child elements that have the specified tagname

toString($indent=0)   X-Ref

return: string string representation of this element

Classe: TXmlDocument  - X-Ref

TXmlDocument class.

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:
<code>
$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;
</code>
The above code represents the following XML string:
<code>
<?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>
</code>

__construct($version='1.0',$encoding='')   X-Ref
Constructor.

param: string version of this XML document
param: string encoding of this XML document

getVersion()   X-Ref

return: string version of this XML document

setVersion($version)   X-Ref

param: string version of this XML document

getEncoding()   X-Ref

return: string encoding of this XML document

setEncoding($encoding)   X-Ref

param: string encoding of this XML document

loadFromFile($file)   X-Ref
Loads and parses an XML document.

param: string the XML file path
return: boolean whether the XML file is parsed successfully

loadFromString($string)   X-Ref
Loads and parses an XML string.
The version and encoding will be determined based on the parsing result.

param: string the XML string
return: boolean whether the XML string is parsed successfully

saveToFile($file)   X-Ref
Saves this XML document as an XML file.

param: string the name of the file to be stored with XML output

saveToString()   X-Ref
Saves this XML document as an XML string

return: string the XML string of this XML document

buildElement($node)   X-Ref
Recursively converts DOM XML nodes into TXmlElement

param: DOMXmlNode the node to be converted
return: TXmlElement the converted TXmlElement

Classe: TXmlElementList  - X-Ref

TXmlElementList class.

TXmlElementList represents a collection of {@link TXmlElement}.
You may manipulate the collection with the operations defined in {@link TList}.

__construct(TXmlElement $owner)   X-Ref
Constructor.

param: TXmlElement owner of this list

getOwner()   X-Ref

return: TXmlElement owner of this list

insertAt($index,$item)   X-Ref
Inserts an item at the specified position.
This overrides the parent implementation by performing additional
operations for each newly added TXmlElement object.

param: integer the speicified position.
param: mixed new item

removeAt($index)   X-Ref
Removes an item at the specified position.
This overrides the parent implementation by performing additional
cleanup work when removing a TXmlElement object.

param: integer the index of the item to be removed.
return: mixed the removed item.



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7