[PATCH] allow XML_Parser & XML_RSS to support string inputs

From: Date: Mon, 28 Jul 2003 00:48:35 +0000
Subject: [PATCH] allow XML_Parser & XML_RSS to support string inputs
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18820@lists.php.net to get a copy of this message
[Note: this is my first time submitting a patch (and making a diff), so please let me know if I did anything wrong] Problem: I am caching RSS feeds in a database. There currently is no way to use XML_RSS on these feeds without having to write them to a temporary file. Fix: Changes are needed to both XML_Parser and XML_RSS. XML_Parser: I didn't take anything out of setInput(). If a resource is passed to setInput(), it works exactly as it does currently. If a non-resource (i.e. string) is passed, it checks to see if it has a scheme (http://, ftp://, etc) and if so, uses the existing setInputFile() to create the resource. If it isn't an absolute URL, it checks to see if the file exists locally. If so, setInputFile() opens it. Finally, if it's a string, it just passes the value through. The changes to parse() are also very minor. Instead of having parseString() executed each time a block of the file is read, the whole file is read into $data first. If $this->fp is a string, it is assigned straight to $data. Either way, $data ends up as the XML for the feed, which is then processed all at once. XML_RSS: Because setInput() checks whether the input is a resource, XML_RSS() doesn't need to do it anymore, so that code is removed. -- Marshall Roch

« previous php.pear.dev (#18820) next »