当前位置: 首页>>代码示例>>C#>>正文


C# XmlDocument.CreateDocumentFragment方法代码示例

本文整理汇总了C#中XmlDocument.CreateDocumentFragment方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.CreateDocumentFragment方法的具体用法?C# XmlDocument.CreateDocumentFragment怎么用?C# XmlDocument.CreateDocumentFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlDocument的用法示例。


在下文中一共展示了XmlDocument.CreateDocumentFragment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAttributesOnDocumentFragment

        public static void GetAttributesOnDocumentFragment()
        {
            var xmlDocument = new XmlDocument();
            var documentFragment = xmlDocument.CreateDocumentFragment();

            Assert.Null(documentFragment.Attributes);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:AttributesTests.cs

示例2: GetSuccessCriteriaInfo

    // 指定された達成基準の情報を返します。
    public XmlNode GetSuccessCriteriaInfo(XmlDocument xml, string id)
    {
        DataRow r = this.Rows.Find(id);

        XmlNode result = xml.CreateDocumentFragment();

            string name = r[NameColumnName].ToString();
            string level = r[LevelColumnName].ToString();

            XmlElement sc = xml.CreateElement("SuccessCriteria");

            XmlElement numberElement = xml.CreateElement("number");
            numberElement.InnerText = id;
            sc.AppendChild(numberElement);

            XmlElement nameElement = xml.CreateElement("name");
            nameElement.InnerText = name;
            sc.AppendChild(nameElement);

            XmlElement levelElement = xml.CreateElement("level");
            levelElement.InnerText = level;
            sc.AppendChild(levelElement);

            result.AppendChild(sc);

        return result;
    }
开发者ID:bakera,项目名称:WAIC-AS-HTML-Generator,代码行数:28,代码来源:SuccessCriteriaTable.cs

示例3: CheckNodeType

        public static void CheckNodeType()
        {
            var xmlDocument = new XmlDocument();
            var documentFragment = xmlDocument.CreateDocumentFragment();

            Assert.Equal(XmlNodeType.DocumentFragment, documentFragment.NodeType);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:CreateDocumentFragment.cs

示例4: GetBodyElement

 private XmlNode GetBodyElement(XmlDocument xml, string elementData)
 {
     string[] dataStrFragments = elementData.Split(NoticeSeparateChars.ToCharArray());
     XmlNode result = xml.CreateDocumentFragment();
     XmlElement body = xml.CreateElement("body");
     string bodyData = null;
     if(dataStrFragments.Length > 1){
         bodyData = dataStrFragments[0];
         for(int i = 1; i < dataStrFragments.Length; i++){
             string noticeTitle = dataStrFragments[i];
             if(++i >= dataStrFragments.Length) break;
             string noticeBody = dataStrFragments[i];
             XmlElement notice = xml.CreateElement("note");
             result.AppendChild(notice);
             AppendElement(notice, "noteTitle", noticeTitle);
             AppendElement(notice, "noteBody", noticeBody);
         }
     } else {
         bodyData = elementData;
     }
     if(!string.IsNullOrEmpty(bodyData)){
         body.InnerText = bodyData;
         result.PrependChild(body);
     }
     return result;
 }
开发者ID:bakera,项目名称:WAIC-AS-HTML-Generator,代码行数:26,代码来源:AsDescriptionTable.cs

示例5: NameOfAllTypes

        public static void NameOfAllTypes()
        {
            var xmlDocument = new XmlDocument();

            var element = xmlDocument.CreateElement("newElem");
            Assert.Equal("newElem", element.Name);

            var attribute = xmlDocument.CreateAttribute("newAttr");
            Assert.Equal("newAttr", attribute.Name);

            var text = xmlDocument.CreateTextNode("");
            Assert.Equal("#text", text.Name);

            var cdata = xmlDocument.CreateCDataSection("");
            Assert.Equal("#cdata-section", cdata.Name);

            var pi = xmlDocument.CreateProcessingInstruction("PI", "");
            Assert.Equal("PI", pi.Name);

            var comment = xmlDocument.CreateComment("some text");
            Assert.Equal("#comment", comment.Name);

            var fragment = xmlDocument.CreateDocumentFragment();
            Assert.Equal("#document-fragment", fragment.Name);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:25,代码来源:NameTests.cs

示例6: EmptyDocumentFragment

        public static void EmptyDocumentFragment()
        {
            var xmlDocument = new XmlDocument();
            var fragment = xmlDocument.CreateDocumentFragment();

            fragment.Normalize();
            Assert.Equal(String.Empty, fragment.OuterXml);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:8,代码来源:NormalizeTests.cs

示例7: OnDocumentFragment

        public static void OnDocumentFragment()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<root><child1/>some text<child2/><child3/></root>");

            var documentFragment = xmlDocument.CreateDocumentFragment();
            documentFragment.AppendChild(xmlDocument.DocumentElement);

            Assert.Null(documentFragment.NextSibling);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:NextSiblingTests.cs

示例8: DocumentFragment

        public static void DocumentFragment()
        {
            var xmlDocument = new XmlDocument();
            var fragment = xmlDocument.CreateDocumentFragment();

            var text1 = xmlDocument.CreateTextNode("test_test1");
            var text2 = xmlDocument.CreateTextNode("test_test2");

            fragment.Normalize();
            Assert.Equal(String.Empty, fragment.OuterXml);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:NormalizeTests.cs

示例9: AllNodesForEmptyString

        public static void AllNodesForEmptyString()
        {
            var xml = "<root>\r\n  text node one\r\n  <elem1 child1=\"\" child2=\"duu\" child3=\"e1;e2;\" child4=\"a1\" child5=\"goody\">\r\n     text node two e1; text node three\r\n  </elem1><!-- comment3 --><?PI3 processing instruction?>e2;<foo /><![CDATA[ <opentag> without an </endtag> and & <! are all ok here ]]><elem2 att1=\"id1\" att2=\"up\" att3=\"attribute3\"><a /></elem2><elem2> \r\n      elem2-text1\r\n      <a> \r\n          this-is-a    \r\n      </a> \r\n\r\n      elem2-text2\r\n      e3;e4;<!-- elem2-comment1-->\r\n      elem2-text3\r\n\r\n      <b> \r\n          this-is-b\r\n      </b>\r\n\r\n      elem2-text4\r\n      <?elem2_PI elem2-PI?>\r\n      elem2-text5\r\n\r\n  </elem2></root>";
            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xml);

            foreach (XmlNode node in xmlDocument.DocumentElement.ChildNodes)
                Assert.Equal(String.Empty, node.NamespaceURI);

            Assert.Equal(String.Empty, xmlDocument.CreateDocumentFragment().NamespaceURI);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:12,代码来源:NamespaceURITests.cs

示例10: ImportDocumentFragment

        public static void ImportDocumentFragment()
        {
            var tempDoc = new XmlDocument();
            var nodeToImport = tempDoc.CreateDocumentFragment();

            nodeToImport.AppendChild(tempDoc.CreateElement("A1"));
            nodeToImport.AppendChild(tempDoc.CreateComment("comment"));
            nodeToImport.AppendChild(tempDoc.CreateProcessingInstruction("PI", "donothing"));

            var xmlDocument = new XmlDocument();
            var node = xmlDocument.ImportNode(nodeToImport, true);

            Assert.Equal(xmlDocument, node.OwnerDocument);
            Assert.Equal(XmlNodeType.DocumentFragment, node.NodeType);
            Assert.Equal(nodeToImport.OuterXml, node.OuterXml);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:16,代码来源:ImportNodeTests.cs

示例11: OwnerDocumentOnImportedTree

        public static void OwnerDocumentOnImportedTree()
        {
            var tempDoc = new XmlDocument();
            var nodeToImport = tempDoc.CreateDocumentFragment();

            nodeToImport.AppendChild(tempDoc.CreateElement("A1"));
            nodeToImport.AppendChild(tempDoc.CreateComment("comment"));
            nodeToImport.AppendChild(tempDoc.CreateProcessingInstruction("PI", "donothing"));

            var xmlDocument = new XmlDocument();
            var node = xmlDocument.ImportNode(nodeToImport, true);

            Assert.Equal(xmlDocument, node.OwnerDocument);

            foreach (XmlNode child in node.ChildNodes)
                Assert.Equal(xmlDocument, child.OwnerDocument);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:17,代码来源:OwnerDocumentTests.cs

示例12: RowToXml

 public virtual XmlNode RowToXml(DataRow row, XmlDocument xml)
 {
     XmlNode result = xml.CreateDocumentFragment();
     AppendElement(result, NumberColumnName, row[NumberColumnName]);
     AppendElement(result, IdColumnName, row[IdColumnName]);
     return result;
 }
开发者ID:waic,项目名称:as_html_generator,代码行数:7,代码来源:CsvDataTable.cs

示例13: ReplaceElementWithDocumentFragmentNode

        public static void ReplaceElementWithDocumentFragmentNode()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<root><child1/></root>");

            var element = xmlDocument.DocumentElement.FirstChild;
            var newDocumentFragment = xmlDocument.CreateDocumentFragment();

            var result = xmlDocument.DocumentElement.ReplaceChild(newDocumentFragment, element);

            Assert.Same(element, result);
            Assert.Null(xmlDocument.DocumentElement.FirstChild);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:ReplaceChildTests.cs

示例14: FirstChildOfNewDocumentFragmentWithChildren

        public static void FirstChildOfNewDocumentFragmentWithChildren()
        {
            var xmlDocument = new XmlDocument();
            var fragment = xmlDocument.CreateDocumentFragment();
            var node1 = xmlDocument.CreateComment("comment");
            var node2 = xmlDocument.CreateCDataSection("some random text");

            fragment.AppendChild(node1);
            fragment.AppendChild(node2);

            Assert.Same(node1, fragment.FirstChild);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:12,代码来源:FirstChildTests.cs

示例15: FirstChildOfNewDocumentFragment

        public static void FirstChildOfNewDocumentFragment()
        {
            var xmlDocument = new XmlDocument();

            Assert.Null(xmlDocument.CreateDocumentFragment().FirstChild);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:6,代码来源:FirstChildTests.cs


注:本文中的XmlDocument.CreateDocumentFragment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。