/** * @param string $url * @param string $node * * @return Feed */ protected function getFeed($url, $node) { $transport = TransportFactory::createTransportFromUrl($url); $reader = new XmlReader(new FileResource($transport)); $reader->setNodeCallback($node); return new Feed($reader); }
/** * @inheritdoc */ public function build(ReaderBuilderInterface $builder, array $options) { parent::build($builder, $options); $reader = new XmlReader([]); $reader->setNodeCallback($options['node_name']); // break into parts $builder->addResourceTransformer(new MultiPartTransformer($reader, new XmlWriter(), $options['part_size'])); }
/** * @dataProvider getTestvalues */ public function testTransformer($xml, array $expected) { $reader = new XmlReader(new StringResource($xml)); $reader->setNodeCallback('foo'); $item = $reader->read(); $transformer = new StripCommentsTransformer(); $transformer->transform($item); $result = $item->all(); $this->assertSame($result, $expected); }
/** * @expectedException \TreeHouse\Feeder\Exception\ReadException * @expectedExceptionMessage Opening and ending tag mismatch */ public function testNextOnInvalidXml() { $reader = new XmlReader(new StringResource('<foo><bar></foo>')); $reader->setNodeCallback('bar'); $reader->next(); }