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


C# XmlDocument.CreateDocumentFragment方法代码示例

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


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

示例1: Create

 public static TwoTransparent2 Create()
 {
     TwoTransparent2 ttxf = new TwoTransparent2();
     XmlDocument doc = new XmlDocument();
     ttxf._frag = doc.CreateDocumentFragment();
     ttxf._frag2 = doc.CreateDocumentFragment();
     ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "3";
     ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "4";
     return ttxf;
 }
开发者ID:hjarvard,项目名称:ObjectXPathNavigator,代码行数:10,代码来源:TwoTransparentXmlFragments.cs

示例2: Create2

		public static TwoTransparentXmlFragments Create2()
		{
			TwoTransparentXmlFragments ttxf = new TwoTransparentXmlFragments();
			ttxf.elem1 = null;
			ttxf.elem3 = null;
			XmlDocument doc = new XmlDocument();
			ttxf._frag = doc.CreateDocumentFragment();
			ttxf._frag2 = doc.CreateDocumentFragment();
			ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "3";
			ttxf._frag2.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "4";
			return ttxf;
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:12,代码来源:TwoTransparentXmlFragments.cs

示例3: CheckNodeType

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

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

示例4: AddHeaderInformation

        public static void AddHeaderInformation(XmlDocument xmlDoc, QMaker qMaker)
        {
            StringBuilder sbH = new StringBuilder();
            StringWriter tempWriterH = new StringWriter(sbH);
            XmlTextWriter writerH = new XmlTextWriter(tempWriterH);

            writerH.WriteStartElement("Headers");

            foreach (QField gField in qMaker.Groups)
            {
                writerH.WriteStartElement("Header");
                writerH.WriteAttributeString("Name", gField.Name);
                writerH.WriteAttributeString("Description", gField.FriendlyName);
                writerH.WriteEndElement();//Header
            }
            foreach (QField fField in qMaker.Fields)
            {
                writerH.WriteStartElement("Header");
                writerH.WriteAttributeString("Name", fField.Name);
                writerH.WriteAttributeString("Description", fField.FriendlyName);
                writerH.WriteEndElement();//Header
            }

            writerH.WriteEndElement();//Headers
            writerH.Flush();

            XmlDocumentFragment xmlHeaders = xmlDoc.CreateDocumentFragment();
            xmlHeaders.InnerXml = sbH.ToString();

            xmlDoc.SelectSingleNode("Report").AppendChild(xmlHeaders);
        }
开发者ID:0anion0,项目名称:IBN,代码行数:31,代码来源:QMetaLoader.cs

示例5: Filter

 /// <summary>
 /// Replaces the read-only Word content controls with XWiki macro markup.
 /// </summary>
 /// <param name="xmlDoc">A reference to the xml document instance.</param>
 public void Filter(ref XmlDocument xmlDoc)
 {
     XmlNodeList macroNodes = xmlDoc.GetElementsByTagName("Sdt", "urn:schemas-microsoft-com:office:word");
     XmlDocumentFragment docFrag = xmlDoc.CreateDocumentFragment();
     Dictionary<String, String> macros = this.manager.States.Macros;
     //We use a new list because the XmlNodeList will break when operationg with its' elements.
     List<XmlNode> nodeList = new List<XmlNode>();
     foreach (XmlNode node in macroNodes)
     {
         nodeList.Add(node);
     }
     foreach (XmlNode node in nodeList)
     {
         try
         {
             String id = node.Attributes["ID"].Value;
             if (macros.ContainsKey(id))
             {
                 String content = macros[id];
                 docFrag.InnerXml = content;
                 node.ParentNode.ReplaceChild(docFrag, node);
             }
         }
         catch (NullReferenceException nre)
         {
             Log.Exception(nre);
         }
         catch (Exception ex)
         {
             Log.Exception(ex);
         }
     }
 }
开发者ID:xwiki-contrib,项目名称:xwiki-office,代码行数:37,代码来源:LocalMacrosAdaptorFilter.cs

示例6: GetAttributesOnDocumentFragment

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

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

示例7: Constructor

		public void Constructor ()
		{
			XmlDocument d = new XmlDocument ();
			XmlDocumentFragment df = d.CreateDocumentFragment ();
			AssertEquals ("#Constructor.NodeName", "#document-fragment", df.Name);
			AssertEquals ("#Constructor.NodeType", XmlNodeType.DocumentFragment, df.NodeType);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:XmlDocumentFragmentTests.cs

示例8: GetResponse

        public ControlResponse GetResponse(Exception ex)
        {
            var env = new XmlDocument();
            env.AppendChild(env.CreateXmlDeclaration("1.0", "utf-8", "yes"));
            var envelope = env.CreateElement("SOAP-ENV", "Envelope", NS_SOAPENV);
            env.AppendChild(envelope);
            envelope.SetAttribute("encodingStyle", NS_SOAPENV, "http://schemas.xmlsoap.org/soap/encoding/");

            var rbody = env.CreateElement("SOAP-ENV:Body", NS_SOAPENV);
            env.DocumentElement.AppendChild(rbody);

            var fault = env.CreateElement("SOAP-ENV", "Fault", NS_SOAPENV);
            var faultCode = env.CreateElement("faultcode");
            faultCode.InnerText = "500";
            fault.AppendChild(faultCode);
            var faultString = env.CreateElement("faultstring");
            faultString.InnerText = ex.ToString();
            fault.AppendChild(faultString);
            var detail = env.CreateDocumentFragment();
            detail.InnerXml = "<detail><UPnPError xmlns=\"urn:schemas-upnp-org:control-1-0\"><errorCode>401</errorCode><errorDescription>Invalid Action</errorDescription></UPnPError></detail>";
            fault.AppendChild(detail);
            rbody.AppendChild(fault);

            return new ControlResponse
            {
                Xml = env.OuterXml,
                IsSuccessful = false
            };
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:29,代码来源:ControlErrorHandler.cs

示例9: SerializeAsXmlNode

		public XmlNode SerializeAsXmlNode(XmlDocument doc)
		{
			System.IO.MemoryStream ms = new MemoryStream();
			XmlSerializer serializer = new XmlSerializer(typeof(ColumnCollection));
			XmlTextReader xRead = null;
			XmlNode xTable = null;
			try
			{
				xTable = doc.CreateNode(XmlNodeType.Element, "TABLE", doc.NamespaceURI);

				serializer.Serialize(ms, this);
				ms.Position = 0;
				xRead = new XmlTextReader( ms );
				xRead.MoveToContent();
				string test = xRead.ReadInnerXml();
				XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
				docFrag.InnerXml = test;

				xTable.AppendChild(docFrag);
			}
			catch(Exception ex)
			{
				throw new Exception("IdentityCollection Serialization Error.", ex);
			}
			finally
			{
				ms.Close();
				if (xRead != null) xRead.Close();
			}
			return xTable;
		}
开发者ID:ViniciusConsultor,项目名称:sqlschematool,代码行数:31,代码来源:IdentityCollection.cs

示例10: Add

        void Add(XmlDocument docFrom,XmlDocument docTo,string id/*,string text*/)
        {
            XmlNodeList nodeList = docFrom.SelectNodes("root/tablename[@ID='"+id+"']");

            string [] text = new string[nodeList.Count];
            foreach(XmlNode curNode in nodeList)
            {
                string curText = curNode.Attributes["Text"].Value;
                Match match = Regex.Match(curText,"\\\\\\d+$");
                int index = 0;
                if(match.Success) index = int.Parse(match.Value.Substring(1));
                text[index] = curText;
                docFrom.DocumentElement.RemoveChild(curNode);
            }
            XmlDocumentFragment docFrag = docTo.CreateDocumentFragment();
            XmlNode parentNode = docFrag;
            foreach(string str in text)
            {
                XmlElement newNode = docTo.CreateElement("treenode");
                newNode.SetAttribute("text",str);
                parentNode.AppendChild(newNode);
                parentNode = newNode;
            }
            docTo.DocumentElement.AppendChild(docFrag);
        }
开发者ID:rags,项目名称:playground,代码行数:25,代码来源:frmBDOTNET.aspx.cs

示例11: XmlNodeWriter

		// It should be public after some tests are done :-)
		public XmlNodeWriter (bool isDocumentEntity)
		{
			doc = new XmlDocument ();
			state = XmlNodeType.None;
			this.isDocumentEntity = isDocumentEntity;
			if (!isDocumentEntity)
				current = fragment = doc.CreateDocumentFragment ();
		}
开发者ID:nobled,项目名称:mono,代码行数:9,代码来源:XmlNodeWriter.cs

示例12: ToXml

 public static XmlNode ToXml(this string xml)
 {
     var doc = new XmlDocument();
     var fragment = doc.CreateDocumentFragment();
     fragment.InnerXml = xml;
     doc.AppendChild(fragment);
     return doc.FirstChild;
 }
开发者ID:MSK61,项目名称:nunit3-vs-adapter,代码行数:8,代码来源:XmlHelper.cs

示例13: TransparentXmlFragment

 public TransparentXmlFragment( bool init )
 {
     elem1 = "3";
     elem3 = "4";
     XmlDocument doc = new XmlDocument();
     _frag = doc.CreateDocumentFragment();
     XmlNode node = _frag.AppendChild( doc.CreateElement( "sub1" ) );
     node.AppendChild( doc.CreateElement( "extra" ) );
     _frag.AppendChild( doc.CreateElement( "sub2" ) ).InnerText = "2";
 }
开发者ID:hjarvard,项目名称:ObjectXPathNavigator,代码行数:10,代码来源:TransparentXmlFragment.cs

示例14: SetInnerXml

		public void SetInnerXml ()
		{
			document = new XmlDocument ();
			fragment = document.CreateDocumentFragment ();
			fragment.InnerXml = "<foo /><bar><child /></bar><baz />";
			AssertEquals ("foo", fragment.FirstChild.Name);
			AssertEquals ("bar", fragment.FirstChild.NextSibling.Name);
			AssertEquals ("child", fragment.FirstChild.NextSibling.FirstChild.Name);
			AssertEquals ("baz", fragment.LastChild.Name);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:XmlDocumentFragmentTests.cs

示例15: 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:johnhhm,项目名称:corefx,代码行数:10,代码来源:NextSiblingTests.cs


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