update xml parsing

This commit is contained in:
Luke Pulverenti 2016-11-02 13:29:06 -04:00
parent 7cf0f79f85
commit 8f64a5555b
5 changed files with 121 additions and 81 deletions

View File

@ -1329,11 +1329,13 @@ namespace MediaBrowser.LocalMetadata.Parsers
protected Share GetShare(XmlReader reader)
{
reader.MoveToContent();
var item = new Share();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -1350,13 +1352,18 @@ namespace MediaBrowser.LocalMetadata.Parsers
item.CanEdit = string.Equals(reader.ReadElementContentAsString(), "true", StringComparison.OrdinalIgnoreCase);
break;
}
default:
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
// This is valid
if (!string.IsNullOrWhiteSpace(item.UserId))

View File

@ -31,11 +31,13 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromCollectionItemsNode(XmlReader reader, MetadataResult<BoxSet> item)
{
reader.MoveToContent();
var list = new List<LinkedChild>();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -55,13 +57,18 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
default:
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
item.Item.LinkedChildren = list;
}

View File

@ -65,11 +65,13 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromCollectionItemsNode(XmlReader reader, Playlist item)
{
reader.MoveToContent();
var list = new List<LinkedChild>();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -89,24 +91,31 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
default:
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
item.LinkedChildren = list;
}
private void FetchFromSharesNode(XmlReader reader, Playlist item)
{
reader.MoveToContent();
var list = new List<Share>();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -126,13 +135,18 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
default:
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
item.Shares = list;
}

View File

@ -513,9 +513,10 @@ namespace MediaBrowser.Providers.TV
using (var reader = XmlReader.Create(streamReader, settings))
{
reader.MoveToContent();
reader.Read();
// Loop through each element
while (reader.Read())
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -546,13 +547,18 @@ namespace MediaBrowser.Providers.TV
break;
}
default:
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
}
}
}

View File

@ -83,14 +83,15 @@ namespace MediaBrowser.Providers.TV
using (reader)
{
reader.MoveToContent();
reader.Read();
// Loop through each element
while (reader.Read())
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
cancellationToken.ThrowIfCancellationRequested();
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "thumb_width":
@ -136,12 +137,17 @@ namespace MediaBrowser.Providers.TV
}
break;
}
default:
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
}