private Unit HandleStartElement(XmlTextReader reader, IObserver <SaxEvent> observer) { _contentHolder = new ContentHolder(_contentHolder); var attributes = new Dictionary <string, string>(); var strUri = reader.NamespaceURI; var strName = reader.Name; var isClosed = reader.IsEmptyElement; if (reader.HasAttributes) { for (var i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); attributes.Add(reader.Name, reader.Value); } } observer.OnNext(new StartElementEvent(strUri, strName, isClosed, new ReadOnlyDictionary <string, string>(attributes))); return(Unit.Default); }
private Unit HandleEndElement(XmlTextReader reader, IObserver <SaxEvent> observer) { var content = _contentHolder.GetContent(); var isClosed = reader.IsEmptyElement; if (isClosed) { content = new List <SaxEvent>(); } else { _contentHolder = _contentHolder.Parent; } var attributes = new Dictionary <string, string>(); var strUri = reader.NamespaceURI; var strName = reader.Name; if (reader.HasAttributes) { for (var i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); attributes.Add(reader.Name, reader.Value); } } var readOnlyAttributes = new ReadOnlyDictionary <string, string>(attributes); var endElementEvent = new EndElementEvent(strUri, strName, isClosed, readOnlyAttributes, content); _contentHolder.Append(endElementEvent); observer.OnNext(endElementEvent); return(Unit.Default); }
public ContentHolder(ContentHolder parent) { _content = new List <SaxEvent>(); Parent = parent; }
public SaxParser() { _contentHolder = new ContentHolder(); }