Save Page As XML


I have made a script that generates an IMDB API link for a movie in XML.

Once this link is generated it will save to an XML file with its contents. The only issue is that the contents aren't saving.

Link generated:<br /><a href="http://imdbapi.org/?title=One+Piece&type=xml&plot=simple&mt=none&episode=0&aka=simple&release=simple" rel="nofollow">http://imdbapi.org/?title=One+Piece&type=xml&plot=simple&mt=none&episode=0&aka=simple&release=simple</a>

PHP script:

$url="http://imdbapi.org/?title=One+Piece&type=xml&plot=simple&mt=none&episode=0&aka=simple&release=simple"; $curl = curl_init(); $data = fopen("text.xml", "w"); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FILE, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_exec ($curl); if ( !$data ) { echo "No"; } else { $contents = curl_exec($curl); fwrite($data, $contents); } curl_close($curl); fclose($data);


Instead of using file_get_contents, you can use CURL

$ch = curl_init('http://imdbapi.org/?title=One+Piece&type=xml&plot=simple&mt=none&episode=0&aka=simple&release=simple'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch);

Now $response shall contains your XML. And you can do something like

file_put_contents('filename.xml', $response);

make sure that filename.xml is writable


  • Is it possible to pass arguments from one controller, to create items of another?
  • how use aggregate functions in child elements using mongodb and c#?
  • JAXB2 maven plugin in eclipse shows error
  • blank Attribute with value in XML with XSLT transformation
  • Add new column to data.frame based on rows grouped by episodes of specific days' length
  • Apache Rewrite CLEAN url?
  • In R, how do I split timestamp interval data into regular slots?
  • Getting Extended File Properties in C# .net
  • Apple Api for Podcast App in Cocoa
  • Rails 3.2.8. Upgrade checkboxes from Rails 1.x.x to 3.2.8
  • select timestamps within ranges
  • What does “render @collection” do?
  • ActiveRecord fails to update HABTM relation
  • Conditional render in tagfile depending on whether the attribute is specified or not
  • Rails 3, Custom Actions, and HTML request methods
  • How to work with AMMediaType for video filters
  • How to repeat sections of a SQL query across UNIONs? (DRY in SQL)
  • C++ cout and enum representations
  • Webgrid not refreshing after delete MVC
  • Could not find rake using whenever rails
  • Jquery UI tool tip close icon
  • ImageMagick, replace semi-transparent white with opaque white
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Cannot connect to cassandra from Spark
  • Display issues when we change from one jquery mobile page to another in firefox
  • Cross-Platform Protobuf Serialization
  • To display the title for the current loaction in map in iphone
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • Matplotlib draw Spline from multiple points
  • Traverse Array and Display in markup
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • Linker errors when using intrinsic function via function pointer
  • Proper folder structure for lots of source files
  • trying to dynamically update Highchart column chart but series undefined
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Turn off referential integrity in Derby? is it possible?
  • Qt: Run a script BEFORE make
  • JaxB to read class hierarchy