getNode() hangs on empty response
ronnievisser opened this issue · 10 comments
Hi,
I'm using the package together with the guzzle parser.I have to load a bunch of xml files into a local database and sometimes i'm getting an empty xml response from the remote server.
when calling the $parser->getNode() method it seems to be hanging since it's cant find the node (uniqueNodeParser).
I can see on the parser class there is a firstNodeFound property but I'm unable to access it.
if there a way to check if there are results without calling the getNode() method?
I just saw that the firstNodeFound property is always false. even as the node is available
Is it reproducable by running the Unique Node Parser on an empty document? Or does it get stuck with Guzzle?
yes, it's reproducable with the file streamer.
test.xml is an empty file.
$stream = new Stream\File(storage_path('app/test.xml'), 1024);
$parser = new Parser\UniqueNode(['uniqueNode' => 'tournament']);
$streamer = new XmlStringStreamer($parser, $stream);
dd($streamer->getNode());
Great, I'll take a look as soon as I find the time. Thanks for reporting!
Until then, you should probably only run it if you've gotten any XML.
That's a bit difficult. I don't know on forehand.
but untill you got it fixed I will use my fork
I just released a new version 0.9.0
that should solve the problem. I bumped the minor because the change might trigger some problems for some extremely weird edge cases.
thanks, much appreciated
can you update the dependency of the guzzle package to this one also?
Ah, yep. I curse the day I chose to split it up into its own repo..
I've released 0.2.0
there with this package's 0.9.0
as requirement.
If you want better control over the Guzzle version and stuff you might want to check out the only, simple, file that the xml-string-streamer-guzzle
package actually consists of: https://github.com/prewk/xml-string-streamer-guzzle/blob/master/src/XmlStringStreamer/Stream/Guzzle.php
Pretty simple to copy and create your own if you'd like. Just a tip.