Created
May 16, 2010 15:46
-
-
Save koduki/402942 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io._ | |
import scala.xml._ | |
def tag2html(text:String) = text.replaceAll("<link caption=\"(.*?)\".*?>(.*?)</link>", "<a href='$2'>$1</a>").replaceAll("<link>(.*?)</link>", "<a href='$1'>$1</a>").replaceAll("<p>(.*?)</p>", "<pre>$1</pre>").replaceAll("<p>(.*?)</p>", "<pre>$1</pre>"); | |
val blog_data = scala.xml.XML.loadFile(new File("/mnt/share/documents/blog.txt")) | |
val article = (blog_data \ "document") toList(3) | |
article \ "@id" | |
article \ "date" text | |
article \ "lastupdate" text | |
article \\ "group" map ( x => x.text) | |
article \\ "title" text | |
article \\ "group" map ( x => "[" + x.text + "]") | |
tag2html(article \\ "content" text) | |
val comments = article \\ "comment" | |
val comment = comments(0) | |
comment \ "@name" text | |
comment \ "@date" text | |
comment text | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment