Methods summary
protected
|
#
_createDocument( string $version = '', string $encoding = '' )
Creates a new XML document using DOMDocument.
Creates a new XML document using DOMDocument.
Parameters
- $version
string $version version of DOMDocument (optional, default: 1.0)
- $encoding
string $encoding encoding of DOMDocumen (optional, default: UTF-8)
|
public
DOMDocument
|
#
getDomDocument( )
Returns the DOMDocument object.
Returns the DOMDocument object.
Returns
DOMDocument
|
public
|
#
setDomDocument( DOMDocument $domDocument )
Sets a current DOMDocument object to class.
Sets a current DOMDocument object to class.
Parameters
- $domDocument
DOMDocument $domDocument DOMDocument object
|
public
string
|
#
getEncoding( )
Returns the encoding of the XML document.
Returns the encoding of the XML document.
Returns
string encoding
Throws
|
public
|
|
protected
|
#
_initXpathInstance( )
Initializes a new DOMXPath instance for DOMDocument.
Initializes a new DOMXPath instance for DOMDocument.
Throws
|
public static
string
|
#
resolvePath( string $path )
Resolves a given path which contains ".." statement for moving up one level
in path.
Resolves a given path which contains ".." statement for moving up one level
in path.
Parameters
- $path
string $path path to resolve
Returns
string resolved path
|
public static
string
|
#
getLevelXpath( string $path, integer $level )
Returns given XPath with integrad level definition.
Returns given XPath with integrad level definition.
Parameters
- $path
string $path XPath to extend
- $level
integer $level level
Returns
string extended XPath
|
public static
SimpleXMLElement
|
#
arrayToXml( array $array, SimpleXMLElement $xml = null, string $rootTagName = 'root' )
Converts an array to a SimpleXMLElement. Example: array(
'key1' => 'value1',
'key2' => array('value21', 'value22'),
'key3' => array('key31' => 'value31', 'key32' => 'value32') );
Converts an array to a SimpleXMLElement. Example: array( 'key1' =>
'value1', 'key2' => array('value21', 'value22'), 'key3' => array('key31'
=> 'value31', 'key32' => 'value32') );
becomes
<?/** Converts an array to a SimpleXMLElement. Example: array( 'key1'
=> 'value1', 'key2' => array('value21', 'value22'), 'key3' =>
array('key31' => 'value31', 'key32' => 'value32') );
becomes
<?xml version="1.0" encoding="utf-8"?> <root>
<key1>value1</key1> <key2>
<array_value>value21</array_value>
<array_value>value22</array_value> </key2> <key3>
<key31>value31</key31> <key32>value32</key32>
</key3> </root>
Parameters
- $array
array $array the array which should be converted to XML
- $xml
SimpleXMLElement $xml [optional] the element to which the array should be added
- $rootTagName
string $rootTagName [optional] the root tag name which should be used - is only used
when $xml is null!
Returns
SimpleXMLElement the array as a SimpleXMLElement
|
public static
|
#
xmlStringToArray( string $xmlString )
Converts the given XML string to an array. Example: <?xml version="1.0"
encoding="utf-8"?> <root> <key1>value1</key1> <key2>
<array_value>value21</array_value>
<array_value>value22</array_value> </key2> <key3>
<key31>value31</key31> <key32>value32</key32>
</key3> </root>
Converts the given XML string to an array. Example: <?xml version="1.0"
encoding="utf-8"?> <root> <key1>value1</key1> <key2>
<array_value>value21</array_value>
<array_value>value22</array_value> </key2> <key3>
<key31>value31</key31> <key32>value32</key32>
</key3> </root>
becomes
array( 'key1' => 'value1', 'key2' => array('value21', 'value22'),
'key3' => array('key31' => 'value31', 'key32' => 'value32') );
Parameters
- $xmlString
string $xmlString contains a valid XML structure
|
public static
|
#
xmlToArray( SimpleXMLElement $xml )
Converts the given SimpleXMLElement object to an array. Example: <?xml
version="1.0" encoding="utf-8"?> <root> <key1>value1</key1>
<key2> <array_value>value21</array_value>
<array_value>value22</array_value> </key2> <key3>
<key31>value31</key31> <key32>value32</key32>
</key3> </root>
Converts the given SimpleXMLElement object to an array. Example: <?xml
version="1.0" encoding="utf-8"?> <root> <key1>value1</key1>
<key2> <array_value>value21</array_value>
<array_value>value22</array_value> </key2> <key3>
<key31>value31</key31> <key32>value32</key32>
</key3> </root>
becomes
array( 'key1' => 'value1', 'key2' => array('value21', 'value22'),
'key3' => array('key31' => 'value31', 'key32' => 'value32') );
Parameters
- $xml
SimpleXMLElement $xml
|
private static
array
|
#
_cleanArray( array $array )
Cleans an array by replacing all empty arrays with empty strings.
Additionally, the function replaces all associative arrays which have only empty
values with the array keys of the array.
Cleans an array by replacing all empty arrays with empty strings.
Additionally, the function replaces all associative arrays which have only empty
values with the array keys of the array.
Parameters
- $array
array $array the array to clean
Returns
array the cleaned array
|