Commit e95bbca0 authored by Tibor Peluch's avatar Tibor Peluch
Browse files

fixed loading of documents with unknown elements

parent 697d0bbe
...@@ -215,15 +215,11 @@ namespace Svg ...@@ -215,15 +215,11 @@ namespace Svg
element = svgDocument; element = svgDocument;
} }
if (element == null)
{
continue;
}
// Add to the parents children // Add to the parents children
if (elementStack.Count > 0) if (elementStack.Count > 0)
{ {
parent = elementStack.Peek(); parent = elementStack.Peek();
if (parent != null && element != null)
parent.Children.Add(element); parent.Children.Add(element);
} }
...@@ -236,11 +232,17 @@ namespace Svg ...@@ -236,11 +232,17 @@ namespace Svg
goto case XmlNodeType.EndElement; goto case XmlNodeType.EndElement;
} }
if (element == null)
{
continue;
}
break; break;
case XmlNodeType.EndElement: case XmlNodeType.EndElement:
// Skip if no element was created and is not the closing tag for the last // Skip if no element was created and is not the closing tag for the last
// known element // known element
if (element == null && reader.LocalName != elementStack.Peek().ElementName) SvgElement topElement = elementStack.Peek();
if (element == null && (topElement != null && reader.LocalName != topElement.ElementName))
{ {
continue; continue;
} }
...@@ -249,6 +251,7 @@ namespace Svg ...@@ -249,6 +251,7 @@ namespace Svg
if (value.Length > 0) if (value.Length > 0)
{ {
if (element != null)
element.Content = value.ToString(); element.Content = value.ToString();
// Reset content value for new element // Reset content value for new element
value = new StringBuilder(); value = new StringBuilder();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment