Skip to content

Instantly share code, notes, and snippets.

@frederickding
Created July 16, 2013 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frederickding/6012347 to your computer and use it in GitHub Desktop.
Save frederickding/6012347 to your computer and use it in GitHub Desktop.
Search for all <wp:post_type> in a WXR file
<?php
$input_file = '/path/to/wxr.wordpress.2013-07-16.xml';
$file = simplexml_load_file($input_file);
$output = fopen($input_file . '.txt', 'w');
// find all instances of <wp:post_type>
$matches = $file->xpath('//wp:post_type');
foreach($matches as $match) {
// write out the contents
fwrite($output, $match->__toString() . "\n");
}
fclose($output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment