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


C# XmlDocument.CreateProcessingInstruction方法代码示例

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


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

示例1: 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

示例2: Query

    // static ?!?!?!?
    public static XmlDocument Query(HttpRequest req, HttpSessionState session,Hashtable xsltParameters)
    {
        XmlDocument inputDoc = new XmlDocument();

        inputDoc.AppendChild(inputDoc.CreateProcessingInstruction("http-redirect", "/"+xsltParameters["base"].ToString()+"/static.cs?page=index"));

        return inputDoc;
    }
开发者ID:sebseb7,项目名称:xsphandler_sharp,代码行数:9,代码来源:index.cs

示例3: BasicCreate

        public static void BasicCreate()
        {
            var xmlDocument = new XmlDocument();
            var newNode = xmlDocument.CreateProcessingInstruction("bar", "foo");

            Assert.Equal("<?bar foo?>", newNode.OuterXml);
            Assert.Equal(XmlNodeType.ProcessingInstruction, newNode.NodeType);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:8,代码来源:CreateProcessingInstruction.cs

示例4: RSSOpret

    public static void RSSOpret(int idvalue)
    {
        DataClassesDataContext db = new DataClassesDataContext();

        List<dbCategory> ListCategory = db.dbCategories.Where(i => i.Id == idvalue).ToList();

        foreach (var itemChannel in ListCategory)
        {
            XmlDocument dom = new XmlDocument();
            XmlProcessingInstruction xpi = dom.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
            dom.AppendChild(xpi);
            XmlElement rss = dom.CreateElement("rss");
            rss.SetAttribute("version", "2.0");

            XmlElement addRes = dom.CreateElement("channel");

            XmlElement navn = dom.CreateElement("title");
            navn.AppendChild(dom.CreateTextNode(itemChannel.Title));
            addRes.AppendChild(navn);

            XmlElement status = dom.CreateElement("description");
            status.AppendChild(dom.CreateTextNode(itemChannel.Description));
            addRes.AppendChild(status);

            XmlElement links = dom.CreateElement("link");
            links.AppendChild(dom.CreateTextNode(Url + "Categories.aspx?category_id='" + itemChannel.Id));
            addRes.AppendChild(links);

            List<dbNew> ListNews = db.dbNews.Where(i => i.CategoryId == idvalue).OrderByDescending(d => d.PostDate).ToList();

            foreach (var item in ListNews)
            {
                XmlElement addNew = dom.CreateElement("item");

                XmlElement titlenews = dom.CreateElement("title");
                titlenews.AppendChild(dom.CreateTextNode(item.Title));
                addNew.AppendChild(titlenews);

                XmlElement statusNew = dom.CreateElement("description");
                statusNew.AppendChild(dom.CreateTextNode(item.Content));
                addNew.AppendChild(statusNew);

                XmlElement linkNew = dom.CreateElement("link");
                linkNew.AppendChild(dom.CreateTextNode(Url + "News.aspx?category_id=" + itemChannel.Id + "&news_id=" + itemChannel.Id));
                addNew.AppendChild(linkNew);

                addRes.AppendChild(addNew);
            }

            rss.AppendChild(addRes);

            dom.AppendChild(rss);
            dom.Save(HttpContext.Current.Server.MapPath("~/feeds/") + itemChannel.Id + "_" + itemChannel.Title + ".xml");

        }
    }
开发者ID:JesperPetersenDk,项目名称:web-integrator-opgaver,代码行数:56,代码来源:Helpers.cs

示例5: InsertNewNodeToElement

        public static void InsertNewNodeToElement()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<a><b/></a>");
            var root = xmlDocument.DocumentElement;
            var newNode = xmlDocument.CreateProcessingInstruction("PI", "pi data");

            root.InsertBefore(newNode, root.FirstChild);

            Assert.Equal(2, root.ChildNodes.Count);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:InsertBeforeTests.cs

示例6: 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

示例7: 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

示例8: RSSOpretKategori

    public static void RSSOpretKategori(int idvalue = 0)
    {
        DataLinqDB db = new DataLinqDB();

        string k = "kategori";

        XmlDocument dom = new XmlDocument();
        XmlProcessingInstruction xpi = dom.CreateProcessingInstruction(
            "xml", "version=\"1.0\" encoding=\"utf‐8\"");
        dom.AppendChild(xpi);
        XmlElement rod = dom.CreateElement("rod");
        rod.SetAttribute("attribut", k);

        List<category> ListCategory;

        if (idvalue > 0)
        {
            ListCategory = db.categories.Where(i => i.category_id == idvalue).ToList();
        }
        else
        {
            ListCategory = db.categories.ToList();
        }

        foreach (var item in ListCategory)
        {
            XmlElement addRes = dom.CreateElement("channel");

            XmlElement navn = dom.CreateElement("title");
            navn.AppendChild(dom.CreateTextNode(item.category_title));
            addRes.AppendChild(navn);

            XmlElement status = dom.CreateElement("description");
            status.AppendChild(dom.CreateTextNode(item.category_description));
            addRes.AppendChild(status);

            XmlElement links = dom.CreateElement("link");
            links.AppendChild(dom.CreateTextNode(Url + "Categories.aspx?category_id='" + item.category_id));
            addRes.AppendChild(links);

            if (idvalue > 0)
            {
                ListCategory = db.news.Where(i => i.fk_categories_id == idvalue).ToList();
            }
            else
            {
                ListCategory = db.news.ToList();
            }

            foreach (var item1 in collection)
            {

            }

            rod.AppendChild(addRes);

            dom.AppendChild(rod);
            dom.Save(HttpContext.Current.Server.MapPath("~/feeds/") + k + ".xml");

        }
    }
开发者ID:JesperPetersenDk,项目名称:web-integrator-opgaver,代码行数:61,代码来源:Helpers.cs

示例9: ProcessingInstructionNode

        public static void ProcessingInstructionNode()
        {
            var xmlDocument = new XmlDocument();
            var node = xmlDocument.CreateProcessingInstruction("PI", "data");

            Assert.Equal("data", node.Value);
            node.Value = "new pi data";
            Assert.Equal("new pi data", node.Value);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:ValueTests.cs

示例10: ReplaceAttributeChildWithProcessingInstruction

        public static void ReplaceAttributeChildWithProcessingInstruction()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<root attr='test'/>");

            var attribute = xmlDocument.DocumentElement.Attributes[0];
            var attributeChild = attribute.FirstChild;
            var newText = xmlDocument.CreateProcessingInstruction("PI", "instructions");

            Assert.Throws<InvalidOperationException>(() => attribute.ReplaceChild(newText, attributeChild));
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:ReplaceChildTests.cs

示例11: FirstChildOfNewProcessingInstruction

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

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

示例12: CheckNoChildrenOnPI

 public static void CheckNoChildrenOnPI()
 {
     var xmlDocument = new XmlDocument();
     Assert.False(xmlDocument.CreateProcessingInstruction("PI", "info").HasChildNodes);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:5,代码来源:HasChildNodesTests.cs

示例13: NewlyCreatedProcessingInstruction

        public static void NewlyCreatedProcessingInstruction()
        {
            var xmlDocument = new XmlDocument();
            var node = xmlDocument.CreateProcessingInstruction("PI", "data");

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

示例14: ProcessingInstructionChildNodeCount

        public static void ProcessingInstructionChildNodeCount()
        {
            var xmlDocument = new XmlDocument();
            var item = xmlDocument.CreateProcessingInstruction("PI", "pi_info");
            var clonedTrue = item.CloneNode(true);
            var clonedFalse = item.CloneNode(false);

            Assert.Equal(0, item.ChildNodes.Count);
            Assert.Equal(0, clonedTrue.ChildNodes.Count);
            Assert.Equal(0, clonedFalse.ChildNodes.Count);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:ChildNodesTests.cs


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