/// <summary>Parses the <state> element.</summary> /// <param name="orphan">The <see cref="Element"/> to add.</param> protected internal override void AddOrphan(Element orphan) { UnknownElement unknown = orphan as UnknownElement; if (unknown != null) { if (StateComponent.Equals(unknown.UnknownData)) { _state.Parse(unknown.InnerText); return; } } base.AddOrphan(orphan); }
/// <summary> /// Adds an unknown element to this instance. /// </summary> /// <param name="element">The element to add.</param> internal void AddUnknownElement(UnknownElement element) { this.AddAsChild(this.unknownElements, element); }
private Element GetElement() { if (_reader.Depth > MaxNestingDepth) { throw new InvalidOperationException("Maximum nesting depth has been reached."); } if (_reader.NodeType != XmlNodeType.Element) { return null; } // Need to check this here before we move to the attributes, // as reader.NodeType will never be EndElement for empty elements // and when we move to an attribute, IsEmptyElement doesn't work bool isEmpty = _reader.IsEmptyElement; Element parent = KmlFactory.CreateElement(this.GetXmlComponent()); if (parent == null) { parent = new UnknownElement(new XmlComponent(_reader)); } else if (parent is IHtmlContent) { this.ProcessAttributes(parent); // No need to process all the children string text = string.Empty; if (!isEmpty) // Is there something to parse? { text = XmlExtractor.FlattenXml(_reader); } ((IHtmlContent)parent).Text = text; return parent; } this.ProcessAttributes(parent); // Empties can have attributes though if (!isEmpty) // Is there any text/children to process? { while (_reader.Read()) { if (_reader.NodeType == XmlNodeType.EndElement) { break; } switch (_reader.NodeType) { case XmlNodeType.Element: this.AddChild(parent); break; case XmlNodeType.CDATA: // Treat like normal text case XmlNodeType.Text: parent.AddInnerText(_reader.Value); break; } } } return parent; }