Jump to content

Populating a mediawiki from tabular data: Difference between revisions

From Squirrel's Lair
Ttenbergen (talk | contribs)
mNo edit summary
Ttenbergen (talk | contribs)
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 31: Line 31:


There are additional xml tags that can be used, to see more example content export a few pages from a wiki and review the XML for examples.
There are additional xml tags that can be used, to see more example content export a few pages from a wiki and review the XML for examples.
[[Category:Mediawiki]]

Latest revision as of 20:09, 2024 March 24


  • Cargo:


  • Categories:
  • Default form


When you first set up a new Mediawiki it is a good idea to populate it with some starting content that uses templates. Sometimes data that needs to go on the wiki is available in tabular form. For example, you may have a spreadsheet to track tools and you want to add this to the wiki.

To make best use of the wiki you will want one page per tool, so you can add all the structured data you want, but also add as much free text as you want. This means you need to add one page per line of spreadsheet, and there could be hundreds of lines.

In this scenario I will often create a new column and use excel functions to generate text of the same format as the XML files generated by an export from Mediawiki. This file can then be imported into the wiki.

Mediawiki import/export files are of the following basic XML structure:

<mediawiki>
 <page><title>mypagetitle</title>
   <revision>
     <text xml:space="preserve">	the content of my page	
     </text><comment>Imported content</comment>    
   </revision>  
 </page>
</mediawiki>

So, the xml for one page can be created by putting a adding a first, third and fifth column with the xml tags.

<page><title> the title </title><revision><text xml:space="preserve"> page content </text><comment>Imported content</comment></revision></page>

The title and the page content can then be generated via excel formula from other columns if needed.

These lines are pasted into a text file, between the <mediawiki> and </mediawiki> tags. That file can then be imported to the wiki via Special Pages, Import pages. A bug on that page means that you have to enter some text into the "interwiki prefix" line or nothing will be imported.

There are additional xml tags that can be used, to see more example content export a few pages from a wiki and review the XML for examples.