
Provides functionality for XML files
This class is implemented to use the UTF-8 character encoding. Please see http://flourishlib.com/docs/UTF-8 for more information.
1.0.0b8 | Fixed a method signature 8/24/11 |
---|---|
1.0.0b7 | Added a workaround for iconv having issues in MAMP 1.9.4+ 7/26/11 |
1.0.0b6 | Updated class to use fCore::startErrorCapture() instead of error_reporting() 8/9/10 |
1.0.0b5 | Added the $fix_entities_encoding parameter to __construct() 8/8/10 |
1.0.0b4 | Updated the class to automatically add a __ prefix for the default namespace and to use that for attribute and child element access 4/6/10 |
1.0.0b3 | Added the $http_timeout parameter to __construct() 9/16/09 |
1.0.0b2 | Added instance functionality for reading of XML files 9/1/09 |
1.0.0b | The initial implementation 1/13/08 |
Custom prefix => namespace URI mappings
array
The dom element for this XML
DOMElement
The XML string for serialization
string
An XPath object for performing xpath lookups
DOMXPath
Encodes content for display in a UTF-8 encoded XML document
string encode( string $content )
string | $content | The content to encode |
The encoded content
Sets the proper Content-Type HTTP header for a UTF-8 XML file
void sendHeader( )
Create the XML object from a string, fFile or URL
The $default_namespace will be used for any sort of methods calls, member access or array access when the element or attribute name does not include a :.
fXML __construct( fFile|string $source, numeric $http_timeout=NULL, boolean $fix_entities_encoding=NULL )
fXML __construct( fFile|string $source, boolean $fix_entities_encoding=NULL )
fFile|string | $source | The source of the XML, either an fFile object, a string of XML, a file path or a URL |
numeric | $http_timeout | The timeout to use in seconds when requesting an XML file from a URL |
boolean | $fix_entities_encoding | This will fix two common XML authoring errors and should only be used when experiencing decoding issues - HTML entities that haven't been encoded as XML, and XML content published in ISO-8859-1 or Windows-1252 encoding without an explicit encoding attribute |
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Allows access to the text content of a child tag
The child element name ($name) may start with a namespace prefix and a : to indicate what namespace it is part of. A blank namespace prefix (i.e. an element name starting with :) is treated as the XML default namespace.
fXML|NULL __get( string $name )
string | $name | The child element to retrieve |
The child element requested
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
The child element name ($name) may start with a namespace prefix and a : to indicate what namespace it is part of. A blank namespace prefix (i.e. an element name starting with :) is treated as the XML default namespace.
boolean __isset( string $name )
string | $name | The child element to check - see method description for details about namespaces |
If the child element is set
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Prevents users from trying to set elements
void __set( string $name, mixed $value )
string | $name | The element to set |
mixed | $value | The value to set |
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
The XML needs to be made into a string before being serialized
array __sleep( )
The members to serialize
Gets the string inside the root XML element
string __toString( )
The text inside the root element
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Prevents users from trying to unset elements
void __unset( string $name )
string | $name | The element to unset |
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
The XML needs to be made into a DOMElement when woken up
void __wakeup( )
Adds a custom namespace prefix to full namespace mapping
This namespace prefix will be valid for any operation on this object, including calls to xpath().
void addCustomPrefix( string $ns_prefix, string $namespace )
string | $ns_prefix | The custom namespace prefix |
string | $namespace | The full namespace it maps to |
Returns the name of the current element
string getName( )
The name of the current element
Returns the namespace of the current element
string getNamespace( )
The namespace of the current element
Returns the namespace prefix of the current element
string getPrefix( )
The namespace prefix of the current element
Returns the string text of the current element
string getText( )
The string text of the current element
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Provides functionality for isset() and empty() (required by arrayaccess interface)
Offsets refers to an attribute name. Attribute may start with a namespace prefix and a : to indicate what namespace the attribute is part of. A blank namespace prefix (i.e. an offset starting with :) is treated as the XML default namespace.
boolean offsetExists( string $offset )
string | $offset | The offset to check |
If the offset exists
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Provides functionality for get [index] syntax (required by ArrayAccess interface)
Offsets refers to an attribute name. Attribute may start with a namespace prefix and a : to indicate what namespace the attribute is part of. A blank namespace prefix (i.e. an offset starting with :) is treated as the XML default namespace.
string offsetGet( string $offset )
string | $offset | The attribute to retrieve the value for |
The value of the offset
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Required by ArrayAccess interface
void offsetSet( integer|string $offset, $value )
integer|string | $offset | The offset to set |
$value |
Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code
Required by ArrayAccess interface
void offsetUnset( integer|string $offset )
integer|string | $offset | The offset to unset |
Performs an XPath query on the current element, returning the raw results
array query( string $path )
string | $path | The XPath path to query |
The matching elements
Returns a well-formed XML string from the current element
string toXML( )
The XML
Executes an XPath query on the current element, returning an array of matching elements
array|string|fXML xpath( string $path, boolean $first_only=FALSE )
string | $path | The XPath path to query |
boolean | $first_only | If only the first match should be returned |
An array of matching elements, or a string or fXML object if $first_only is TRUE