PHP Class Microweber\Utils\lib\XmlStreamer
Copyright (c) 2014 Oskar Thornblad (
[email protected]), contributions from Valiton GmbH, Michael Härtl
https://github.com/prewk/XmlStreamer
Licensed under MIT:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
显示文件
Open project: microweber/microweber
Public Methods
Method |
Description |
|
__construct ( $mixed, $chunkSize = 16384, $customRootNode = null, $totalBytes = null, $customChildNode = null ) |
|
|
chunkCompleted ( ) |
Called after a chunk was completed. Useful to chunk INSERT data into DB. |
|
getReadBytes ( ) |
Gets the total read bytes so far. |
|
getTotalBytes ( ) |
Gets the total file size of the xml. |
|
init ( ) |
Called after the constructor completed setup of the class. Can be overriden in a child class. |
|
parse ( ) |
Starts the streaming and parsing of the XML file. |
|
processNode ( $xmlString, $elementName, $nodeIndex ) : If |
Gets called for every XML node that is found as a child to the root node. |
|
Private Methods
Method Details
__construct()
public method
public __construct ( $mixed, $chunkSize = 16384, $customRootNode = null, $totalBytes = null, $customChildNode = null ) |
$mixed |
|
Path to XML file OR file handle |
$chunkSize |
|
Bytes to read per cycle (Optional, default is 16 KiB) |
$customRootNode |
|
Specific root node to use (Optional) |
$totalBytes |
|
Xml file size - Required if supplied file handle |
chunkCompleted()
public method
Called after a chunk was completed. Useful to chunk INSERT data into DB.
getReadBytes()
public method
Gets the total read bytes so far.
getTotalBytes()
public method
Gets the total file size of the xml.
Called after the constructor completed setup of the class. Can be overriden in a child class.
Starts the streaming and parsing of the XML file.
processNode()
abstract public method
Gets called for every XML node that is found as a child to the root node.
abstract public processNode ( $xmlString, $elementName, $nodeIndex ) : If |
$xmlString |
|
Complete XML tree of the node as a string |
$elementName |
|
Name of the node for easy access |
$nodeIndex |
|
Zero-based index that increments for every node |
return |
If |
false is returned, the streaming will stop |