WordPress is importing xml file as txt and adding it to media

Posted July 3, 2020 1.2k views

In my WordPress install when I try to run the importer to import an xml file, the .txt extension is being added to the end and the file ends up in the media library. I receive this error ‘The export file could not be found at /var/www/html/wp-content/uploads/2020/07/****.xml_.txt. It is likely that this was caused by a permissions problem.’ I’m stuck with this and haven’t been able to find anything related to the issue.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @stu1106,

In most cases you have a PHP extension missing that’s preventing it from working properly. In your case, You’ll need to install the PHP DomDocument extension. This extension is actually contained in XML.

Do you know if you are using Ubuntu or Apache? If it’s Ubuntu, you can use the following command

sudo apt-get install php-xml

If you are using CentOS

yum install php-xml


  • Hi @KFSys,

    Thanks for the reply. I am using Ubuntu, I tried the command you suggested yesterday but it seems it is already installed, this is the message I get after I run that:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    php-xml is already the newest version (1:7.2+60ubuntu1).
    The following packages were automatically installed and are no longer required:
      linux-headers-4.15.0-106 linux-headers-4.15.0-106-generic
      linux-headers-4.15.0-74 linux-headers-4.15.0-74-generic
      linux-image-4.15.0-106-generic linux-image-4.15.0-74-generic
      linux-modules-4.15.0-106-generic linux-modules-4.15.0-74-generic
    Use 'sudo apt autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 140 not upgraded.


    • Hmm, that’s odd. Are you sure you have only one PHP version installed on the droplet? Maybe you need to install xml for another version like so :

      sudo apt-get install php74-xml

      That’s for PHP 7.4. If you are using any other like 7.2 or 7.1 just replace them in the command.

Hi @stu1106,

With the plugin are you getting the same issue?

One other thing, can you try and install PHP 7.4 with the following commands:

sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt -y install php7.4
sudo apt-get install -y php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}

You’ll need to add a few more extensions to your php7.4 - dom, gmagick, SimpleXML, ssh2, XML, xmlreader, curl, date, exit, filter , ftp, gd, hash, iconv, imagick, json, libxml, mbstring, mysqli, openssl, pcre, posix, sockets, SPL, tokenizer, zlib, pdo.

All of the extensions should be installed like so

apt-get install -y php7.4-iconv


  • Hi @KFSys I have done the above but still the same issue. With the plugin you suggested I couldn’t get the posts imported correctly due to constraints within the plugin itself, I’m trying to import some polls but the parameters didn’t really allow me to. I did have some success with other plugins in that they managed to import the posts with the title, but none of the content, so it doesn’t appear to be the same issue with those plugins.