public void TestCachedQueryAttr(string xml, string selector, string expectedValue) { IssueSink s = new IssueSink("XmlTests"); Node n = Node.FromXmlFragment(xml, s); //Node, all start and end tags must match in case. XML rules. Assert.AreEqual(expectedValue, n.queryAttr(selector)); IEnumerable<IIssue> issues = s.GetIssues(); if (issues != null) foreach (IIssue issue in issues) Debug.Write(issue.ToString()); }
public static Node FromXmlFragment(string xml, IssueSink sink) { NameTable nt = new NameTable(); XmlNamespaceManager nsmanager = new XmlNamespaceManager(nt); XmlParserContext context = new XmlParserContext(nt, nsmanager, "elem", XmlSpace.None, System.Text.Encoding.UTF8); XmlTextReader reader = new XmlTextReader(xml, XmlNodeType.Element, context); Node n = new Node(new XmlDocument().ReadNode(reader) as XmlElement, sink); reader.Close(); return n; }