PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / trunk
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets vtrunk
3.9.5 3.9.6 4.0.0 4.0.1 4.1.0 trunk 2.12 2.13 2.14 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.3-beta-1.0 3.7.4 3.7.4-beta-1.0 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4
wp-all-import / classes / XmlStreamReader / prewk / xml-string-streamer / src / XmlStringStreamer.php
wp-all-import / classes / XmlStreamReader / prewk / xml-string-streamer / src Last commit date
XmlStringStreamer 1 month ago XmlStringStreamer.php 10 years ago
XmlStringStreamer.php
77 lines
1 <?php
2 /**
3 * xml-string-streamer base class
4 *
5 * @package xml-string-streamer
6 * @author Oskar Thornblad <oskar.thornblad@gmail.com>
7 */
8
9 namespace Prewk;
10
11 use Prewk\XmlStringStreamer\ParserInterface;
12 use Prewk\XmlStringStreamer\StreamInterface;
13 use Prewk\XmlStringStreamer\Parser;
14 use Prewk\XmlStringStreamer\Stream;
15
16 /**
17 * The base class for the xml-string-streamer
18 */
19 class XmlStringStreamer
20 {
21 /**
22 * The current parser
23 * @var ParserInterface
24 */
25 protected $parser;
26 /**
27 * The current stream
28 * @var StreamInterface
29 */
30 protected $stream;
31
32 /**
33 * Constructs the XML streamer
34 * @param ParserInterface $parser A parser with options set
35 * @param StreamInterface $stream A stream for the parser to use
36 */
37 public function __construct(ParserInterface $parser, StreamInterface $stream)
38 {
39 $this->parser = $parser;
40 $this->stream = $stream;
41 }
42
43 /**
44 * Convenience method for creating a StringWalker parser with a File stream
45 * @param string|resource $file File path or handle
46 * @param array $options Parser configuration
47 * @return XmlStringStreamer A streamer ready for use
48 */
49 public static function createStringWalkerParser($file, $options = array())
50 {
51 $stream = new Stream\File($file, 16384);
52 $parser = new Parser\StringWalker($options);
53 return new XmlStringStreamer($parser, $stream);
54 }
55
56 /**
57 * Convenience method for creating a UniqueNode parser with a File stream
58 * @param string|resource $file File path or handle
59 * @param array $options Parser configuration
60 * @return XmlStringStreamer A streamer ready for use
61 */
62 public static function createUniqueNodeParser($file, $options = array())
63 {
64 $stream = new Stream\File($file, 16384);
65 $parser = new Parser\UniqueNode($options);
66 return new XmlStringStreamer($parser, $stream);
67 }
68
69 /**
70 * Gets the next node from the parser
71 * @return bool|string The xml string or false
72 */
73 public function getNode()
74 {
75 return $this->parser->getNodeFrom($this->stream);
76 }
77 }