Easily Import any XML or CSV File to WordPress

I am looking for a WordPress plugin which easily creates Posts (or Pages or any Custom Post Types) from the content of XML or CSV datafeed

If you have something like this, please let me know, I searched our marketplace but I couldn’t find such an item.

Try this - http://wordpress.org/extend/plugins/wp-all-import/

Thank you :slight_smile: I knew about this one, but the features mentioned are only contained in the pro version which is about 99$ which is a bit too much :slight_smile:

I see. I imagine this is for a personal project then?

Developing something like the pro version would cost more than $100 of my time and much more if I had someone else make it for me. So, I consider the cost of pro version fairly inexpensive if you’re charging enough for client work or passing the cost to the client.

Good luck finding what you’re looking for. :wink:

I have something on my hard drive called “HaxVaQ: The Syntax Synthesizer”… It cross-formats an array of different data structures into a variety of others… I made it during a slow week, but it’s not exactly tuned for this type of activity, although it’s quite capable… I have no intention of distributing it, but here is the XML conversion function (PHP):

function xml_to_array ($xml_url, $target='', $nested='')
{
  $data = ''; $i=0;
  $xml_file = fopen($xml_url, "rb");
  while (!feof($xml_file))
  {
    $data .= fread($xml_file, 2048);
  }
  fclose($xml_file);
  $data = preg_replace("/<([a-z]+?)( .+?=.+?)>/i", "<$1>", $data);
  preg_match_all("/<".$target.">([\w\W\r
]+?)<\/".$target.">/i", $data, $data2);
  unset($dat2[0]); unset($data);
  
  $c = count($data2[1]);
  $output['count'] = $c;
  foreach ($data2[1] as $xml)
  {
    $i++;
    
    /*preg_match("//i", $xml, $link);*/
    preg_match("//i", $xml, $link);
    $output[$i]['link'] = $link[1]; unset($link);
    
    $xml = preg_replace("/<[^>]+?\/>/i", "", $xml);
    //$xml = preg_replace("/<([a-z]+?)( .+?=.+?)>/i", "<$1>", $xml); <--- MOVED TO LINE 17
    if ($nested)
    {
      preg_match_all("/<".$nested.">([\w\W\r
]+?)<\/".$nested.">/i", $xml, $ndata);
      preg_match_all("/<(.+?)>([\w\W\r
]+?)<\/.+?>/i", $ndata[1][0], $nested_fields);
      unset($ndata);
      
      foreach ($nested_fields[1] as $k => $v)
      {
        $output[$i][$nested][$v] = $nested_fields[2][$k];
      }
      unset($nested_fields);
      $xml = preg_replace("/<".$nested.">([\w\W\r
]+?)<\/".$nested.">/i", "", $xml);
    }
    
    preg_match_all("/<(.+?)>([\w\W\r
]+?)<\/.+?>/i", $xml, $fields);
    unset($xml);
    
    foreach ($fields[1] as $k => $v)
    {
      if (preg_match("//i", $fields[2][$k]))
        $output[$i][$v] = preg_replace("//i", "$1", $fields[2][$k]);
      else
      {
        $fields[2][$k] = str_ireplace("<", "<", $fields[2][$k]);
        $fields[2][$k] = str_ireplace(">", ">", $fields[2][$k]);
        $output[$i][$v] = strip_tags($fields[2][$k]);
      }
    }
    unset($fields);
  }
  
  return $output;
}

You use it like this:
print_r(xml_to_array("http://appworld.blackberry.com/webstore/rss/featured", "item"));

or if the XML feed has nested items you want:
print_r(xml_to_array("http://parabasis.typepad.com/blog/atom.xml", "entry", "author"));

I hope this helps :)