开发者

What file format can I use to output a formatted text file straight from a program without having the markup be too complicated?

Premise:

I am parsing a file that is quite nearly XML, but not quite. From this file I would like to extract data and output in a file that a user could open up in some program and read. To make the data reasonable, I would almost certainly need to format the text. In case it matters, I will probably be using Java to write the program.

Problem:

I cannot find a file format that supports formatting without having terribly complex rules and encoding problems.

Attempts:

  • I looked into a basic .txt extension first, but it does not h开发者_如何学Goave enough formatting advantage.
  • I then tried a .rtf extension, but the rules for outputting text seem to be terribly complicated.
  • It was then suggested that I used XML, but I do not understand how this file would be viewed. This appears to be probably the best solution, but I don't understand much about it. Perhaps somebody could shed some light here.

In Other Words:

Could somebody suggest and easy to use file format and/or shed some light on how to use XML for text formatting and viewing?


How about plain HTML? simple formatting, readable everywheree.


XML is good, and most web browsers have some kind of tree-like xml display.

Another option might be to use comma-separated values, make up some structure, and import into Excel or other spreadsheet for viewing.

(edit -- For various reasons, I was gravitating towards something that was also machine readable, like a downstream tool might like it. The other answer of HTML is also excellent!)


Check out YAML. It is quite simple and easy to read.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜