public void ParseHtmlEntityInXmlShouldThrowError() { var source = @" <title> </title>"; var parser = new XmlParser(); Assert.Catch<XmlParseException>(() => { var document = parser.Parse(source); }); }
public void ParseHtmlStructureInXmlShouldThrowError() { var source = @" <title>My Title</title> <p>My paragraph</p>"; var parser = new XmlParser(); Assert.Catch<XmlParseException>(() => { var document = parser.Parse(source); }); }
public void ParseInvalidXmlEntityShouldBeSerialized() { var source = @" <title> </title>"; var parser = new XmlParser(new XmlParserOptions { IsSuppressingErrors = true }); var document = parser.Parse(source); Assert.AreEqual(" ", document.DocumentElement.TextContent); }
public void ParseValidXmlEntityShouldBeRepresentedCorrectly() { var source = @" <title>&</title>"; var parser = new XmlParser(new XmlParserOptions { IsSuppressingErrors = true }); var document = parser.Parse(source); Assert.AreEqual("&", document.DocumentElement.TextContent); }
public void ParseHtmlEntityInXmlShouldNotThrowErrorIfSuppressed() { var source = @" <title> </title>"; var parser = new XmlParser(new XmlParserOptions { IsSuppressingErrors = true }); var document = parser.Parse(source); Assert.AreEqual(1, document.Children.Length); }
public void ParseHtmlStructureInXmlShouldNotThrowErrorIfSuppressed() { var source = @" <title>My Title</title> <p>My paragraph</p>"; var parser = new XmlParser(new XmlParserOptions { IsSuppressingErrors = true }); var document = parser.Parse(source); Assert.AreEqual(1, document.Children.Length); }
public void ObtainElementPositionsFromXml() { var positions = new Dictionary<IElement, TextPosition>(); var source = @"<hello> <foo /> <bar> <test></test><test></test><test></test> </bar> </hello>"; var parser = new XmlParser(new XmlParserOptions { OnCreated = (element, position) => positions[element] = position }); var document = parser.Parse(source); Assert.AreEqual(6, positions.Count); }
public static IDocument ToXmlDocument(this String sourceCode, IConfiguration configuration = null) { var xmlParser = new XmlParser(configuration); return xmlParser.Parse(sourceCode); }