Skip to content
Yauheni Pakala edited this page Apr 26, 2016 · 2 revisions

Introduction

Here is an example of loading FB2 file into FB2File class object:

Read from Stream

private async Task ReadFB2FileStreamAsync(Stream stream)
{
	// setup
	var readerSettings = new XmlReaderSettings
	{
		DtdProcessing = DtdProcessing.Ignore
	};
	var loadSettings = new XmlLoadSettings(readerSettings);

	try
	{
		// reading
		FB2File file = await new FB2Reader().ReadAsync(stream, loadSettings);
	}
	catch (Exception ex)
	{
		Debug.WriteLine(string.Format("Error loading file : {0}", ex.Message));
	}
}

Read from string

// ... reading xml file and get string to `xml` ...

// read fb2 file as a string
FB2File file = await new FB2Reader().ReadAsync(xml)
Clone this wiki locally