xiaoxing tech

February 14, 2008

Java Learning: Key Areas Map

Filed under: Java — xiaoxing @ 9:39 pm

February 8, 2008

Generate an XML file from a text file

Filed under: asp.net, xml — xiaoxing @ 3:09 pm

I have a text file ch1.txt (link), in Chinese. It is the first chapter of The Book of Liezi.
Also, I have another text file which is the English version of the same chapter.
My purpose is to design a webpage, with both Chinese and English versions, display the text in parallel, like this:

列子 卷第一 天瑞篇
Book 1 – Cosmogony

子列子居鄭圃,四十年人無識者。
MASTER LIEH (Lieh Tzu) dwelt on a vegetable plot in the Chêng State for forty years, and no man knew him for what he was.

Instead of doing this manually, I’d like to do it in a managable way. My first step is to convert the text file into an XML file, with
the following structure:

<chapter id="1">
<intro>列子 卷第一 天瑞篇</intro>
<p id="1">
<ptitle>only eng</ptitle>
<text>子列子居鄭圃…</text>
<comment></comment>
</p>
<p id="2">
<ptitle>only eng</ptitle>
<text>子列子曰:「昔者聖人…</text>
<comment></comment>
</p>
</chapter>

the code is here: http://liezi.info/not_website/XmlWriterTest.zip

Blog at WordPress.com.