title: Converting XML or HTML to Wiki mark up - what approach would you choose?
body: <p>I need to convert HTML documents (generated from <a href="http://en.wikipedia.org/wiki/DocBook" rel="nofollow noreferrer">DocBook</a> XML documents) to the Wiki mark up language, in particular to the <a href="http://www.pmwiki.org" rel="nofollow noreferrer">PM Wiki</a> mark up language. The goal is to include the company's application operations guides in our newly created wiki. This means that I actually have two options:</p>
  
  <ol>
  <li>Convert the HTMLs (generated from DocBook XMLs) to wiki</li>
  <li>Convert the Docbook XMLs directly to wiki</li>
  </ol>
  
  <p>Since the HTMLs are generated by a DocBook to HTML converter, the way the tags are defined within the HTML documents do not vary much, only the contents of the documents.</p>
  
  <p>I am looking for a solution that could be implemented quickly by myself. I will have to do this conversion once and then every time new versions of the application operations guides are created.</p>
  
  <p>Solutions that I've thought of so far:</p>
  
  <ol>
  <li>Convert HTML to wiki with a Perl or PHP script, based on regular expressions. </li>
  <li>Convert Docbook XMLs directly to wiki. Since it is XML, I could use Java for XML parsing. The risk here is that I am not familiar with the DocBooks XML format (as I am with HTML), so this make take some time to learn.</li>
  </ol>
  
  <p>What approach would you choose for this work?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I just tried a PMWiki extension called <a href="http://www.pmwiki.org/wiki/Cookbook/ConvertHTML" rel="nofollow noreferrer">ConvertHTML</a>. It did not work well, because it does not convert HTML tags (e.g.  is not converted as is left as  in the wiki), as its documentation says:</p>
  
  <p><em>PmWiki markup does not support all of the HTML markup so a 100% conversion is not possible. However, PmWiki can make replacements to the text as it is being edited or saved. ConvertHTML implements a relatively comprehensive set of rules for converting HTML tags to wiki markup.</em> </p>