Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9053639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:28:30+00:00 2026-06-16T13:28:30+00:00

I created a little script that imports wordpress posts from an xml file: if(isset($_POST[‘wiki_import_posted’]))

  • 0

I created a little script that imports wordpress posts from an xml file:

if(isset($_POST['wiki_import_posted'])) {

    // Get uploaded file
    $file = file_get_contents($_FILES['xml']['tmp_name']);
    $file = str_replace('&', '&', $file);

    // Get and parse XML
    $data = new SimpleXMLElement( $file , LIBXML_NOCDATA);

    foreach($data->RECORD as $key => $item) {

        // Build post array
        $post = array(
            'post_title' => $item->title,
            ........
        );

        // Insert new post
        $id = wp_insert_post( $post );
    }
}

The problem is that my xml file is really big, and when i submit the form, the browser just hangs for a couple of minutes.

Is it possible to display some messages during the import, like displaying a dot after every item is imported?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:28:31+00:00Added an answer on June 16, 2026 at 1:28 pm

    Unfortunately, no, not easily. Especially if you’re building this on top of the WP framework you’ll find it not worth your while at all. When you’re interacting with a PHP script you are sending a request and awaiting a response. However long it takes that PHP script to finish processing and start sending output is how long it usually takes the client to start seeing a response.

    There are a few things to consider if what you want is for output to start showing as soon as possible (i.e. as soon as the first echo or output statement is reached).

    1. Turn off output buffering so that output begins sending immediately.
    2. Output whatever you want inside the loop that would indicate to you the progress you wish to be know about.

    Note that if you’re doing this with an AJAX request content may not be ready immediately to transport to the DOM via your XMLHttpRequest object. Also note that some browsers do their own buffering before content can be ready for the user to display (like IE for example).

    Some suggestions you may want to look into to speed up your script, however:

    • Why are you doing str_replace(‘&’,’&’,$file) on a large file? You realize that has cost with no benefit, right? You’ve acomplished nothing and if you meant you want to replace the HTML entity & then you probably have some of your logic very wrong. Encoding is something you want to let the XML parser handle.
    • You can use curl_multi instead of file_get_contents to do multiple HTTP requests concurrently to save time if you are transferring a lot of files. It will be much faster since it’s none-blocking I/O.
    • You should use DOMDocument instead of SimpleXML and a DOMXPath query can get you your array much faster than what you’re currently doing. It’s a much nicer interface than SimpleXML and I always recommend it above SimpleXML since in most cases SimpleXML makes things incredibly difficult to do and for no good reason. Don’t let the name fool you.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently started working with pointers and have created a little script that is supposed
I've created a script that downloads very large files from the internet. Something quite
I wrote this little BASH script that creates a folder,unzips Wordpress and creates a
I've created a little script for displaying a calendar but the month is 1
I'm a jQuery newbie, and I have trouble with a little script I created.
I've just created a little app that programmatically compiles code using the C# Compiler,
I'm just starting out learning javascript, and tried to write a little script that
I've written a little script in JAVA, that tests the parameter limit with four
Hi i've created a nice little jquery sliding panel that works great on the
I have a little problem about that. When i create a script with VS2012

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.