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


C# XmlDocument.ImportNode方法代码示例

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


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

示例1: SignXml

        // Sign an XML file.  
        // This document cannot be verified unless the verifying  
        // code has the key with which it was signed. 
        public static void SignXml(XmlDocument xmlDoc, RSA Key)
        {
            // Check arguments. 
            if (xmlDoc == null)
                throw new ArgumentException("xmlDoc");
            if (Key == null)
                throw new ArgumentException("Key");

            // Create a SignedXml object.
            SignedXml signedXml = new SignedXml(xmlDoc);

            // Add the key to the SignedXml document.
            signedXml.SigningKey = Key;

            // Create a reference to be signed.
            Reference reference = new Reference();
            reference.Uri = "";

            // Add an enveloped transformation to the reference.
            XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
            reference.AddTransform(env);

            // Add the reference to the SignedXml object.
            signedXml.AddReference(reference);

            // Compute the signature.
            signedXml.ComputeSignature();

            // Get the XML representation of the signature and save 
            // it to an XmlElement object.
            XmlElement xmlDigitalSignature = signedXml.GetXml();

            // Append the element to the XML document.
            xmlDoc.DocumentElement.AppendChild(xmlDoc.ImportNode(xmlDigitalSignature, true));
        }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:38,代码来源:SignXML.cs

示例2: ImportNullNode

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

            Assert.Throws<InvalidOperationException>(() => xmlDocument.ImportNode(null, false));
            Assert.Throws<InvalidOperationException>(() => xmlDocument.ImportNode(null, true));
        }
开发者ID:nandhanurrevanth,项目名称:corefx,代码行数:7,代码来源:ImportNodeTests.cs

示例3: Create

        public override XmlNode Create()
        {
            XmlDocument xmldoc = new XmlDocument();
            XmlAttribute attrId = xmldoc.CreateAttribute("id");
            attrId.Value = Identifier;

            XmlNode set = xmldoc.CreateElement("Set");
            set.Attributes.Append(attrId);

            foreach (NxElement elem in m_elements)
            {
                set.AppendChild(xmldoc.ImportNode(elem.Create(), true));
            }

            foreach (NxLogic logic in m_logic)
            {
                set.AppendChild(xmldoc.ImportNode(logic.Create(), true));
            }

            NxLogic logicBlock = BuildConditionGroupLogicBlock();
            if (logicBlock != null)
            {
                XmlNode node = logicBlock.Create();
                set.AppendChild(xmldoc.ImportNode(node, true));
            }
            return set;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:27,代码来源:NxConditionSet.cs

示例4: btnExportPackageXml_Click

        private void btnExportPackageXml_Click(object sender, EventArgs e)
        {
            if (tabPackages.SelectedTab == null) return;
            cPackage p = ServerPackages.Packages.GetPackage(tabPackages.SelectedTab.Text);
            if (p == null) return;

            XmlDocument xmlPackageOut = new XmlDocument();

            XmlNode nodeDeclaration = ServerPackages.Packages._xml.FirstChild;
            if(nodeDeclaration == null) return;
            XmlNode nodeDeclarationImport = xmlPackageOut.ImportNode(nodeDeclaration, false);

            XmlNode nodePackage = ServerPackages.Packages._xml.SelectSingleNode("//name[.='" + p.Name + "']").ParentNode;
            if (nodePackage == null) return;
            XmlNode nodePackageImport = xmlPackageOut.ImportNode(nodePackage, true);

            xmlPackageOut.AppendChild(nodeDeclarationImport);
            xmlPackageOut.AppendChild(nodePackageImport);

            string strLocalPackageFile = txtPackagesFile.Text + "\\" + p.Name + "\\package.xml";
            if (File.Exists(strLocalPackageFile))
            {
                string strFileDest = txtPackagesFile.Text + "\\package_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + "." + DateTime.Now.Minute.ToString() + "." + DateTime.Now.Second.ToString() + ".xml";
                File.Copy(strLocalPackageFile, strFileDest);
            }

            xmlPackageOut.Save(strLocalPackageFile);
        }
开发者ID:DanstonCube,项目名称:Lanceur,代码行数:28,代码来源:Form1.cs

示例5: GetNotificationMail

        public NotificationMail GetNotificationMail(string notificationType)
        {
            try
            {
                var notifications = new XmlDocument();
                notifications.Load(Config.ConfigurationFile);

                var settings = notifications.SelectSingleNode("//global");

                var node = notifications.SelectSingleNode(string.Format("//instant//notification [@name = '{0}']", notificationType));

                var details = new XmlDocument();
                var cont = details.CreateElement("details");
                cont.AppendChild(details.ImportNode(settings, true));
                cont.AppendChild(details.ImportNode(node, true));

                var detailsChild = details.AppendChild(cont);

                var notificationMail = new NotificationMail
                {
                    FromMail = detailsChild.SelectSingleNode("//email").InnerText,
                    FromName = detailsChild.SelectSingleNode("//name").InnerText,
                    Subject = detailsChild.SelectSingleNode("//subject").InnerText,
                    Domain = detailsChild.SelectSingleNode("//domain").InnerText,
                    Body = detailsChild.SelectSingleNode("//body").InnerText
                };

                return notificationMail;
            }
            catch (Exception e)
            {
                LogHelper.Error<MarkAsSolutionReminder>(string.Format("Couldn't get settings for {0}", notificationType), e);
                throw;
            }
        }
开发者ID:umbraco,项目名称:OurUmbraco,代码行数:35,代码来源:NotificationMail.cs

示例6: CompileLevel

        public XmlDocument CompileLevel( XmlDocument xmlDocument )
        {
            var result = new XmlDocument( );
            var rootElement = result.CreateNode( XmlNodeType.Element, "level", string.Empty );

            var environmentData = xmlDocument.SelectSingleNode( "//environment" );

            if ( environmentData != null )
            {
                XmlNode environmentResult = _environmentParser.Serialize( xmlDocument );
                XmlNode environmentNode = result.ImportNode( environmentResult.LastChild, true );
                rootElement.AppendChild( environmentNode );
            }

            var entityData = xmlDocument.SelectSingleNode( "//nodes" );

            if ( entityData != null )
            {
                XmlNode entitiesResult = _entityParser.Serialize( xmlDocument );
                XmlNode entitiesNode = result.ImportNode( entitiesResult.LastChild, true );
                rootElement.AppendChild( entitiesNode );
            }

            result.AppendChild( rootElement );
            return result;
        }
开发者ID:nkostelnik,项目名称:factions_editor,代码行数:26,代码来源:LevelCompiler.cs

示例7: OutputXML

        public XmlDocument OutputXML(int interval, Page page, IDnaDiagnostics diagnostics)
        {
            XmlDocument xDoc = new XmlDocument();
            XmlNode xmlEl = xDoc.AppendChild(xDoc.CreateElement("H2G2"));
            xmlEl.Attributes.Append(xDoc.CreateAttribute("TYPE"));
            xmlEl.Attributes["TYPE"].InnerText = "STATUSPAGE";
            xmlEl = xmlEl.AppendChild(xDoc.CreateElement("STATUS-REPORT"));
            xmlEl.AppendChild(xDoc.ImportNode(Statistics.CreateStatisticsDocument(interval).FirstChild, true));

            XmlDocument xmlSignal = new XmlDocument();
            xmlSignal.LoadXml(StringUtils.SerializeToXmlUsingXmlSerialiser(SignalHelper.GetStatus(diagnostics)));
            xmlEl.AppendChild(xDoc.ImportNode(xmlSignal.DocumentElement, true));

            try
            {
                var memcachedCacheManager = (MemcachedCacheManager)CacheFactory.GetCacheManager("Memcached");
                xmlEl.AppendChild(xDoc.ImportNode(memcachedCacheManager.GetStatsXml(), true));
            }
            catch (Exception e)
            {
                var childNode = xmlEl.AppendChild(xDoc.CreateElement("MEMCACHED_STATUS"));
                childNode.InnerText = "Error getting memcached stats:" + e.Message;
            }

            return xDoc;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:26,代码来源:StatusUI.cs

示例8: OutputXML

        private void OutputXML(int interval)
        {
            XmlDocument xDoc = new XmlDocument();
            XmlNode xmlEl = xDoc.AppendChild(xDoc.CreateElement("H2G2"));
            xmlEl.Attributes.Append(xDoc.CreateAttribute("TYPE"));
            xmlEl.Attributes["TYPE"].InnerText = "STATUSPAGE";
            xmlEl = xmlEl.AppendChild(xDoc.CreateElement("STATUS-REPORT"));
            xmlEl.AppendChild(xDoc.ImportNode(Statistics.CreateStatisticsDocument(interval).FirstChild, true));

            XmlDocument xmlSignal = new XmlDocument();
            xmlSignal.LoadXml(StringUtils.SerializeToXmlUsingXmlSerialiser(SignalHelper.GetStatus(Global.dnaDiagnostics)));
            xmlEl.AppendChild(xDoc.ImportNode(xmlSignal.DocumentElement, true));

            try
            {
                var memcachedCacheManager = (MemcachedCacheManager)CacheFactory.GetCacheManager("Memcached");
                xmlEl.AppendChild(xDoc.ImportNode(memcachedCacheManager.GetStatsXml(), true));
            }
            catch (Exception e)
            {
                var childNode = xmlEl.AppendChild(xDoc.CreateElement("MEMCACHED_STATUS"));
                childNode.InnerText = "Error getting memcached stats:" + e.Message;
            }

            Response.ContentType = "text/xml";
            Response.Clear();
            Response.Write(xDoc.InnerXml);
            Response.End();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:29,代码来源:status.aspx.cs

示例9: Create

        public XmlNode Create()
        {
            XmlDocument xmldoc = new XmlDocument();
            XmlNode deNode = xmldoc.CreateElement("DataElement");

            XmlAttribute attrName = xmldoc.CreateAttribute("Name");
            attrName.Value = m_DataElement.Name.Value;

            XmlAttribute attrType = xmldoc.CreateAttribute("type");
            attrType.Value = NxUtils.DataTypeToString(m_DataElement.Type);

            deNode.Attributes.Append(attrName);
            deNode.Attributes.Append(attrType);

            IEnumerator<KeyValuePair<string, IPolicyLanguageItem>> enumerator = m_DataElement.GetAttributeEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair<string, IPolicyLanguageItem> pair = enumerator.Current;
                XmlAttribute attrib = xmldoc.CreateAttribute(pair.Key);
                attrib.Value = pair.Value.Value;
                deNode.Attributes.Append(attrib);
            }

            if (m_DataElement.Data is IDataItem)
            {
                XmlNode diNode = new NxDataItem(m_DataElement.Data as IDataItem).Create();
                deNode.AppendChild(xmldoc.ImportNode(diNode, true));
            }
            else if (m_DataElement.Data is IPolicyObjectCollection<IDataItem>)
            {
                IPolicyObjectCollection<IDataItem> dataitems = m_DataElement.Data as IPolicyObjectCollection<IDataItem>;
                foreach (IDataItem di in dataitems)
                {
                    XmlNode diNode = new NxDataItem(di).Create();
                    deNode.AppendChild(xmldoc.ImportNode(diNode, true));
                }
            }
            else if (m_DataElement.Data is IDataSource)
            {
                XmlNode dsNode = new NxDataSource(m_DataElement.Data as IDataSource).Create();
                deNode.AppendChild(xmldoc.ImportNode(dsNode, true));
            }
            else if (m_DataElement.Data is IPolicyObjectCollection<IDataSource>)
            {
                IPolicyObjectCollection<IDataSource> datasources = m_DataElement.Data as IPolicyObjectCollection<IDataSource>;
                foreach (IDataSource ds in datasources)
                {
                    XmlNode dsNode = new NxDataSource(ds).Create();
                    deNode.AppendChild(xmldoc.ImportNode(dsNode, true));
                }
            }
            return deNode;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:53,代码来源:NxDataElement.cs

示例10: Serialize

        public XmlNode Serialize()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<GameState/>");

            doc.DocumentElement.AppendChild(doc.ImportNode(Units.Serialize(), true));
            doc.DocumentElement.AppendChild(doc.ImportNode(Effects.Serialize(), true));
            doc.DocumentElement.AppendChild(doc.ImportNode(Projectiles.Serialize(), true));
            doc.DocumentElement.AppendChild(doc.ImportNode(Blocks.Serialize(), true));

            return doc.DocumentElement;
        }
开发者ID:EttienneS,项目名称:Contingency,代码行数:12,代码来源:GameState.cs

示例11: UpdateWsdlWithPolicyInfo

        public static string UpdateWsdlWithPolicyInfo(string wsdlData, List<ServiceEndpoint> endpoints, string interfaceName)
        {
            // load the input wsdl info into an XmlDocument so we can append and prepend
            // the policy nodes as appropriate
            XmlDocument inputWsdlDoc = new XmlDocument();
            inputWsdlDoc.LoadXml(wsdlData);

            // Export the endpoints and related bindings
            XmlDocument wcfWsdlDoc = ExportEndpoints(endpoints);


            XmlNamespaceManager nsMgr = new XmlNamespaceManager(wcfWsdlDoc.NameTable);
            nsMgr.AddNamespace("wsp", Constants.NsWsp);
            nsMgr.AddNamespace("wsdl", Constants.NsWsdl);
            nsMgr.AddNamespace("wsu", Constants.NsWsu);

            XmlNodeList policyNodes = wcfWsdlDoc.DocumentElement.SelectNodes("wsp:Policy", nsMgr);

            // Process bottom-up to preserve the original order.
            for (int i = policyNodes.Count - 1; i >= 0; i--)
            {
                XmlNode policyNode = policyNodes[i];
                XmlAttribute IdAttribute = policyNode.Attributes["Id", Constants.NsWsu];
                IdAttribute.Value = IdAttribute.Value.Replace(Constants.InternalContractName, interfaceName);
                XmlNode importedNode = inputWsdlDoc.ImportNode(policyNode, true);
                inputWsdlDoc.DocumentElement.PrependChild(importedNode);
            }

            XmlNodeList bindingNodes = wcfWsdlDoc.DocumentElement.SelectNodes("wsdl:binding", nsMgr);
            for (int i = bindingNodes.Count - 1; i >= 0; i--)
            {
                XmlNode bindingNode = bindingNodes[i];
                XmlNode policyRef = bindingNode.SelectSingleNode("wsp:PolicyReference", nsMgr);
                if (policyRef != null)
                {
                    policyRef.Attributes["URI"].Value = policyRef.Attributes["URI"].Value.Replace(Constants.InternalContractName, interfaceName);
                    string xPath = string.Format("wsdl:binding[@name=\"{0}\"]",
                        bindingNode.Attributes["name"].Value.Replace(Constants.InternalContractName, interfaceName));

                    XmlNode ourBindingNode = inputWsdlDoc.DocumentElement.SelectSingleNode(xPath, nsMgr);
                    XmlNode importedNode = inputWsdlDoc.ImportNode(policyRef, true);
                    ourBindingNode.PrependChild(importedNode);
                }
            }

            // finally return the string contents of the processed xml file
            return inputWsdlDoc.OuterXml;

        }
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:49,代码来源:PolicyWriter.cs

示例12: GenerateForGenerateSolution

        public XmlDocument GenerateForGenerateSolution(string platform, IEnumerable<XmlElement> projectElements)
        {
            var doc = new XmlDocument();
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
            var input = doc.CreateElement("Input");
            doc.AppendChild(input);

            var generation = doc.CreateElement("Generation");
            var platformName = doc.CreateElement("Platform");
            platformName.AppendChild(doc.CreateTextNode(platform));
            var hostPlatformName = doc.CreateElement("HostPlatform");
            hostPlatformName.AppendChild(doc.CreateTextNode(_hostPlatformDetector.DetectPlatform()));
            generation.AppendChild(platformName);
            generation.AppendChild(hostPlatformName);
            input.AppendChild(generation);

            var featuresNode = doc.CreateElement("Features");
            foreach (var feature in _featureManager.GetAllEnabledFeatures())
            {
                var featureNode = doc.CreateElement(feature.ToString());
                featureNode.AppendChild(doc.CreateTextNode("True"));
                featuresNode.AppendChild(featureNode);
            }
            input.AppendChild(featuresNode);

            var projects = doc.CreateElement("Projects");
            input.AppendChild(projects);

            foreach (var projectElem in projectElements)
            {
                projects.AppendChild(doc.ImportNode(projectElem, true));
            }

            return doc;
        }
开发者ID:marler8997,项目名称:Protobuild,代码行数:35,代码来源:SolutionInputGenerator.cs

示例13: main

        private void main(string path)
        {
            XmlNodeList N2;

            Essay_exam_withSentence_reader essay_exam_withSentence_reader = new Essay_exam_withSentence_reader();
            N2 = essay_exam_withSentence_reader.question_reader(path);

            Essay_exam_answer_writer essay_exam_answer_writer = new Essay_exam_answer_writer();
            essay_exam_answer_writer.setpath(".\\xml\\exam_answer.xml");

            Essay_AE_find_sentence essay_AE_find_sentence = new Essay_AE_find_sentence();

            foreach(XmlNode n2 in N2)
            {
                XmlDocument xmldocument = new XmlDocument();
                XmlNode new_n2 = xmldocument.ImportNode(n2, true);
                List<string> Answer;
                Answer = essay_AE_find_sentence.findanswer(new_n2);
                essay_exam_answer_writer.write_answer(new_n2, Answer);
            }

            essay_exam_answer_writer.save();

            MessageBox.Show("finish AE");
        }
开发者ID:Steven-Tsai,项目名称:IMTKU_NTCIR_QALab2,代码行数:25,代码来源:Form1.cs

示例14: GenerateFloatingLicense

        /// <summary>
        /// Floating 라이선스를 생성합니다.
        /// 참고 : http://en.wikipedia.org/wiki/Floating_licensing
        /// </summary>
        /// <param name="privateKey">제품의 Private Key</param>
        /// <param name="name">라이선스 명</param>
        /// <param name="publicKey">제품의 Public Key</param>
        /// <returns>Floating License의 XML 문자열</returns>
        public static string GenerateFloatingLicense(string privateKey, string name, string publicKey) {
            if(IsDebugEnabled)
                log.Debug("Floating License를 생성합니다... privateKey=[{0}], name=[{1}], publicKey=[{2}]", privateKey, name, publicKey);

            using(var rsa = new RSACryptoServiceProvider()) {
                rsa.FromXmlString(privateKey);

                var doc = new XmlDocument();
                var licenseElement = doc.CreateElement(LicensingSR.FloatingLicense);
                doc.AppendChild(licenseElement);

                var publicKeyElement = doc.CreateElement(LicensingSR.LicenseServerPublicKey);
                licenseElement.AppendChild(publicKeyElement);
                publicKeyElement.InnerText = publicKey;

                var nameElement = doc.CreateElement(LicensingSR.LicenseName);
                licenseElement.AppendChild(nameElement);
                nameElement.InnerText = name;

                var signatureElement = GetXmlDigitalSignature(doc, rsa);
                doc.FirstChild.AppendChild(doc.ImportNode(signatureElement, true));

                using(var ms = new MemoryStream())
                using(var xw = XmlWriter.Create(ms, new XmlWriterSettings
                                                    {
                                                        Indent = true,
                                                        Encoding = Encoding.UTF8
                                                    })) {
                    doc.Save(xw);
                    ms.Position = 0;
                    return new StreamReader(ms).ReadToEnd();
                }
            }
        }
开发者ID:debop,项目名称:NFramework,代码行数:42,代码来源:LicenseTool.cs

示例15: Main

		static int Main (string [] args)
		{
			if (args.Length != 2) {
				Console.WriteLine ("Usage: mono gen-apidiff-html.exe <diff_dir> <html_file>");
				return 1;
			}

			string diff_dir = args[0];
			string out_file = args[1];

			var all = new XmlDocument ();
			all.AppendChild(all.CreateElement ("assemblies"));
			foreach (string file in Directory.EnumerateFiles(diff_dir, "*.apidiff")) {
				Console.WriteLine ("Merging " + file);
				var doc = new XmlDocument ();
				doc.Load (file);
				foreach (XmlNode child in doc.GetElementsByTagName ("assembly")) {
					XmlNode imported = all.ImportNode (child, true);
					all.DocumentElement.AppendChild (imported);
				}
			}

			var transform = new XslCompiledTransform ();
			transform.Load ("mono-api.xsl");
			var writer = new StreamWriter (out_file);

			Console.WriteLine (String.Format ("Transforming to {0}...", out_file));
			transform.Transform (all.CreateNavigator (), null, writer);
			writer.Close ();

			return 0;
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:32,代码来源:gen-apidiff-html.cs


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