Here are the examples of the csharp api System.Xml.XmlReader.ReadOuterXmlAsync() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
Source : AniDbSeriesProvider.cs
with GNU General Public License v2.0
from jellyfin-archive
with GNU General Public License v2.0
from jellyfin-archive
private static async Task ExtractEpisodes(string seriesDataDirectory, string seriesDataPath)
{
var settings = new XmlReaderSettings
{
Async = true,
CheckCharacters = false,
IgnoreProcessingInstructions = true,
IgnoreComments = true,
ValidationType = ValidationType.None
};
using (var streamReader = new StreamReader(seriesDataPath, Encoding.UTF8))
{
// Use XmlReader for best performance
using (var reader = XmlReader.Create(streamReader, settings))
{
await reader.MoveToContentAsync().ConfigureAwait(false);
// Loop through each element
while (await reader.ReadAsync().ConfigureAwait(false))
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "episode")
{
var outerXml = await reader.ReadOuterXmlAsync().ConfigureAwait(false);
await SaveEpsiodeXml(seriesDataDirectory, outerXml).ConfigureAwait(false);
}
}
}
}
}
}
19
Source : AniDbSeriesProvider.cs
with GNU General Public License v2.0
from jellyfin-archive
with GNU General Public License v2.0
from jellyfin-archive
private static async Task ExtractCast(string cachePath, string seriesDataPath)
{
var settings = new XmlReaderSettings
{
Async = true,
CheckCharacters = false,
IgnoreProcessingInstructions = true,
IgnoreComments = true,
ValidationType = ValidationType.None
};
var cast = new List<AniDbPersonInfo>();
using (var streamReader = new StreamReader(seriesDataPath, Encoding.UTF8))
{
// Use XmlReader for best performance
using (var reader = XmlReader.Create(streamReader, settings))
{
await reader.MoveToContentAsync().ConfigureAwait(false);
// Loop through each element
while (await reader.ReadAsync().ConfigureAwait(false))
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "characters")
{
var outerXml = await reader.ReadOuterXmlAsync().ConfigureAwait(false);
cast.AddRange(ParseCharacterList(outerXml));
}
if (reader.NodeType == XmlNodeType.Element && reader.Name == "creators")
{
var outerXml = await reader.ReadOuterXmlAsync().ConfigureAwait(false);
cast.AddRange(ParseCreatorsList(outerXml));
}
}
}
}
var serializer = new XmlSerializer(typeof(AniDbPersonInfo));
foreach (var person in cast)
{
var path = GetCastPath(person.Name, cachePath);
var directory = Path.GetDirectoryName(path);
Directory.CreateDirectory(directory);
if (!File.Exists(path) || person.Image != null)
{
try
{
using (var stream = File.Open(path, FileMode.Create))
{
serializer.Serialize(stream, person);
}
}
catch (IOException)
{
// ignore
}
}
}
}