[Code Snippet] Parse FB2 format book in C#
Here is the actual code snippet to parse FB2 format book using C#. FB2 File format is known as FictionBook format. FB2 is rather simple file format based on XML and basic HTML. The FB2 file contains sections. Sections can contain other sections as well as paragraphs. Paragraphs contain actual text and basic formatting.
The program below loads all sections recursively and print their names to console. Also one can use the fb2verse variable to get the actual text of the paragraph. The approach below uses the XDocument class to get the XElements. The only trick with further parsing is to use the correct XNamespace.