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:
The above code represents the following XML string:
- $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;
- <?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>
Located in /Xml/TXmlDocument.php (line 307)
TComponent | --TXmlElement | --TXmlDocument
Constructor.
Loads and parses an XML document.
Loads and parses an XML string.
The version and encoding will be determined based on the parsing result.
Saves this XML document as an XML file.
Saves this XML document as an XML string
Magic-method override. Called whenever this document is used as a string.
or
- $document = new TXmlDocument();
- $document->TagName = 'root';
- echo $document;
- $document = new TXmlDocument();
- $document->TagName = 'root';
- $xml = (string)$document;
Inherited From TXmlElement
TXmlElement::__construct()
TXmlElement::getAttribute()
TXmlElement::getAttributes()
TXmlElement::getElementByTagName()
TXmlElement::getElements()
TXmlElement::getElementsByTagName()
TXmlElement::getHasAttribute()
TXmlElement::getHasElement()
TXmlElement::getParent()
TXmlElement::getTagName()
TXmlElement::getValue()
TXmlElement::setAttribute()
TXmlElement::setParent()
TXmlElement::setTagName()
TXmlElement::setValue()
TXmlElement::toString()
TXmlElement::__toString()
Inherited From TComponent
TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Documentation generated on Mon, 21 Apr 2008 11:36:52 -0400 by phpDocumentor 1.3.0RC4