Automated file upload to mediawiki

If you want to create wiki pages in your mediawiki automatically from a shell you can use curl to perform a http-upload request to import a preformatted xml file ...:

 curl -F "xmlimport=@/tmp/YourXmlFile.xml;source=upload;action=submit;edittoken=1235" "http://www.example.com/yourwiki/index.php?title=Special:Import&action=submit"

(12345 is just some random number) ... The xml file should look something like this:

<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="de">
  <siteinfo>
    <sitename>YourWikiName</sitename>
    <base>http://www.example.com/yourwiki/index.php/Main_page</base>
    <case>first-letter</case>
  </siteinfo>
  <page>
    <title>{{PAGE_TITLE_HERE}}</title>
    <revision>
     <contributor>
      <username>YourUserAccount</username>
      <id>YourUserID</id>
     </contributor>
      <minor/>
      <text xml:space="preserve">
{{{YOUR_WIKI_TEXT_HERE}}}
      </text>
    </revision>
  </page>
</mediawiki>

If you use your wiki for documentation, this can be very useful to automate documentation tasks. It can easily be used from a shell script ...