コード例 #1
0
        public void WriteNodeXPathNavigatorAttribute()
        {
            string            xml = "<!DOCTYPE root [<!ELEMENT root EMPTY> <!ATTLIST root implicit NMTOKEN 'nam'>]><root attr='val' />";
            XPathNavigator    nav = new XPathDocument(new StringReader(xml)).CreateNavigator();
            XmlWriterSettings s   = new XmlWriterSettings();

            s.OmitXmlDeclaration = true;
            StringWriter sw = new StringWriter();
            XmlWriter    w  = XmlWriter.Create(sw, s);

            w.WriteStartElement("hoge");
            nav.MoveToFirstChild();
            nav.MoveToFirstAttribute();
            w.WriteNode(nav, false);
            nav.MoveToNextAttribute();
            w.WriteNode(nav, false);
            w.Close();
            AssertType.AreEqual("<hoge />", sw.ToString());
        }