コード例 #1
0
ファイル: XmlTests.cs プロジェクト: stukalin/ImageResizer
 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());
 }
コード例 #2
0
ファイル: Node.cs プロジェクト: stukalin/ImageResizer
        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;
        }