當前位置: 首頁>>代碼示例>>C#>>正文


C# Xml.XmlNodeReader類代碼示例

本文整理匯總了C#中System.Xml.XmlNodeReader的典型用法代碼示例。如果您正苦於以下問題:C# XmlNodeReader類的具體用法?C# XmlNodeReader怎麽用?C# XmlNodeReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlNodeReader類屬於System.Xml命名空間,在下文中一共展示了XmlNodeReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WMIBMySQL

 public WMIBMySQL()
 {
     string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
     Core.RecoverFile(file);
     if (File.Exists(file))
     {
         Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
         XmlDocument document = new XmlDocument();
         using (TextReader sr = new StreamReader(file))
         {
             document.Load(sr);
             using (XmlNodeReader reader = new XmlNodeReader(document.DocumentElement))
             {
                 XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
                 Unwritten un = (Unwritten)xs.Deserialize(reader);
                 lock (unwritten.PendingRows)
                 {
                     unwritten.PendingRows.AddRange(un.PendingRows);
                 }
             }
         }
     }
     Thread reco = new Thread(Exec) {Name = "MySQL/Recovery"};
     Core.ThreadManager.RegisterThread(reco);
     reco.Start();
 }
開發者ID:benapetr,項目名稱:wikimedia-bot,代碼行數:26,代碼來源:MySQL.cs

示例2: Create

        public static EvaluationEngine Create(XmlDocument policyDoc, IXacmlPolicyRepository ch) {
            Contract.Requires<ArgumentNullException>(policyDoc != null);

            using (XmlReader reader = new XmlNodeReader(policyDoc.DocumentElement)) {
                return EvaluationEngineFactory.Create(reader, ch);
            }
        }
開發者ID:abc-software,項目名稱:abc.xacml,代碼行數:7,代碼來源:EvaluationEngineFactory.cs

示例3: RetargetWithMetadataConverter

        /// <remarks>Internal for testing.</remarks>
        internal static void RetargetWithMetadataConverter(XDocument xdoc, Version targetSchemaVersion, MetadataConverterDriver converter)
        {
            Debug.Assert(xdoc != null, "xdoc != null");
            Debug.Assert(EntityFrameworkVersion.IsValidVersion(targetSchemaVersion), "invalid target schema version");

            var inputXml = new XmlDocument { PreserveWhitespace = true };
            using (var reader = xdoc.CreateReader())
            {
                inputXml.Load(reader);
            }

            var outputXml = converter.Convert(inputXml, targetSchemaVersion);
            if (outputXml != null)
            {
                // Dev10 Bug 550594: There is a bug in XmlEditor that prevents from deleting the root node
                // unless the root node has previous sibling (like a comment or Xml declaration).
                if (xdoc.Root.PreviousNode == null)
                {
                    xdoc.Root.AddBeforeSelf(new XComment(""));
                }

                // update xml document with new root element
                xdoc.Root.Remove();
                using (var reader = new XmlNodeReader(outputXml))
                {
                    var newDoc = XDocument.Load(reader);
                    xdoc.Add(newDoc.Root);
                }

                // Do not reload artifact here
                // Until the transaction is commited, the XLinq representation of the parsed xml tree hasn't been generated yet.
            }
        }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:34,代碼來源:RetargetXmlNamespaceCommand.cs

示例4: ReadConfig

 private static CassandraSharpConfig ReadConfig(XmlDocument xmlDoc)
 {
     XmlSerializer xmlSer = new XmlSerializer(typeof(CassandraSharpConfig));
     //MiniXmlSerializer xmlSer = new MiniXmlSerializer(typeof(CassandraSharpConfig));
     using (XmlReader xmlReader = new XmlNodeReader(xmlDoc))
         return (CassandraSharpConfig)xmlSer.Deserialize(xmlReader);
 }
開發者ID:kpaskal,項目名稱:cassandra-sharp,代碼行數:7,代碼來源:SectionHandler.cs

示例5: TransformNode

        public static void TransformNode(XmlNode element, XmlReader xslTemplate)
        {
            XmlReader reader = new XmlNodeReader(element);

              XmlReader transformResultReader = TransformXml(reader, xslTemplate, null);
              element.CreateNavigator().ReplaceSelf(transformResultReader);
        }
開發者ID:okyereadugyamfi,項目名稱:softlogik,代碼行數:7,代碼來源:XslUtils.cs

示例6: ToXDocument

 /// <summary>
 /// Converts XmlDocument to XDocument using load options.
 /// </summary>
 /// <param name="document">
 /// The input document to be converted.
 /// </param>
 /// <param name="options">
 /// The options for the conversion.
 /// </param>
 /// <returns>
 /// Resulting XDocument.
 /// </returns>
 public static XDocument ToXDocument(this XmlDocument document, LoadOptions options)
 {
     using (XmlNodeReader reader = new XmlNodeReader(document))
     {
         return XDocument.Load(reader, options);
     }
 }
開發者ID:chien-andalou,項目名稱:QuickRoutes,代碼行數:19,代碼來源:XmlDocumentExtensions.cs

示例7: ToBackpackObject

        // converts the given xml document to an object of the given type.
        public static IBackpackObject ToBackpackObject(this XmlDocument xmlDocument, System.Type objType)
        {
            XmlNodeReader xmlNodeReader = new XmlNodeReader(xmlDocument.DocumentElement);
            XmlSerializer xmlSerializer = new XmlSerializer(objType);

            return (IBackpackObject)xmlSerializer.Deserialize(xmlNodeReader);
        }
開發者ID:jonezy,項目名稱:backpackapi,代碼行數:8,代碼來源:ExtensionMethods.cs

示例8: Read

        public static void Read(XmlDocument xml)
        {
            List<DecModel> list = new List<DecModel>();
            XNamespace ns = "HTTP://CLIS.HB_DEC";

            using (var nodeReader = new XmlNodeReader(xml))
            {
                nodeReader.MoveToContent();
                XDocument xdoc= XDocument.Load(nodeReader);

                var seqNo = xdoc.Descendants(ns + "SEQ_NO").First().Value;
                var entryId = xdoc.Descendants(ns + "ENTRY_ID").First().Value;
                var ieFlag = xdoc.Descendants(ns + "I_E_FLAG").First().Value;

                foreach (var element in xdoc.Descendants(ns + "HB_DEC_LIST"))
                {
                    Console.WriteLine(element.Element(ns + "COP_G_NO").Value, element.Element(ns + "QTY").Value);
                    DecModel item = new DecModel();
                    item.EntryId = entryId;
                    item.SeqNo = seqNo;
                    item.IEFlag = ieFlag;
                    item.GNo = element.Element(ns + "COP_G_NO").Value;
                    item.Qty = Convert.ToDecimal(element.Element(ns + "QTY").Value);
                    list.Add(item);
                }

                if (list.Count > 0)
                {
                    SqlHelper.Insert(list);
                }
               

            }
        }
開發者ID:neozhu,項目名稱:Kaifa.B2B.Solution,代碼行數:34,代碼來源:HBDec.cs

示例9: fillCountry

        public static void fillCountry(ComboBox objCmbCountry,String CountryCode)
        {
            //DataTable objDT = new DataTable("Country");
            //DataRow objRow;
            //DataColumn objcol =new DataColumn("ContryName",typeof(System.String));
            //objDT.Columns.Add(objcol);

            //objcol =new DataColumn("ContryId",typeof(System.String));
            //objDT.Columns.Add(objcol);

            XmlNodeReader objXmlReader;
            DataSet ds = new DataSet();
            XmlDocument  objOutXml = new XmlDocument();
            String strInput = "<MS_LISTCOUNTRY_OUTPUT><COUNTRY  COUNTRY_CODE='0' COUNTRY_NAME='Select one'/><COUNTRY  COUNTRY_CODE='BD' COUNTRY_NAME='Bangladesh'/><COUNTRY  COUNTRY_CODE='IN' COUNTRY_NAME='India' /><COUNTRY  COUNTRY_CODE='NP' COUNTRY_NAME='Nepal' /> <COUNTRY  COUNTRY_CODE='LK' COUNTRY_NAME='Srilanka' /><COUNTRY  COUNTRY_CODE='BT' COUNTRY_NAME='Bhutan' /><COUNTRY  COUNTRY_CODE='ML' COUNTRY_NAME='Maldives' /><COUNTRY  COUNTRY_CODE='TB' COUNTRY_NAME='TBA' /> <Errors Status='False'><Error Code='' Description='' /></Errors></MS_LISTCOUNTRY_OUTPUT>";
            objOutXml.LoadXml(strInput);

            objXmlReader = new XmlNodeReader(objOutXml);
            ds.ReadXml(objXmlReader);
            objCmbCountry.DataSource = ds.Tables["COUNTRY"];
            objCmbCountry.DisplayMember = "COUNTRY_NAME";
            objCmbCountry.ValueMember = "COUNTRY_CODE";
            objCmbCountry.SelectedIndex = 0;
            if (CountryCode !="")
            {
                objCmbCountry.SelectedIndex = objCmbCountry.FindString("India");
            }
        }
開發者ID:ngoswami1978,項目名稱:Query-Scheduler-CSharp,代碼行數:27,代碼來源:QueryClass.cs

示例10: Deserialise

 private static Projects Deserialise(XmlDocument xmlDoc)
 {
     var nodeReader = new XmlNodeReader(xmlDoc);
     nodeReader.ReadToDescendant("Projects");
     var result = Serialiser.Deserialize(nodeReader);
     return (Projects)result;
 }
開發者ID:azdlowry,項目名稱:GoDashboard,代碼行數:7,代碼來源:PipelineDeserialiser.cs

示例11: BindData

		public void BindData()
        {
            #region 綁定輪換圖片列表
            DataGrid1.AllowCustomPaging = false;
			DataGrid1.DataKeyField = "rotatepicid";
            DataGrid1.TableHeaderName = "聚合輪換圖片列表";

			XmlDocumentExtender xmldocument = new XmlDocumentExtender();
			xmldocument.Load(configPath);
			XmlNode node = xmldocument.SelectSingleNode(targetNode);
            if (node == null || node.ChildNodes.Count == 0)
            {
                DataGrid1.Visible = SaveRotatepic.Visible = false;
                return;
            }
			XmlNodeReader rdr = new XmlNodeReader(node);
			dsSrc.ReadXml(rdr);
            dsSrc.Tables[0].Columns.Add("rowid");
            int i = 0;
            foreach (DataRow dr in dsSrc.Tables[0].Rows)
            {
                dr["rowid"] = i.ToString();
                i++;
            }
			DataGrid1.DataSource = dsSrc.Tables[0];
			DataGrid1.DataBind();
            #endregion
        }
開發者ID:ChalmerLin,項目名稱:dnt_v3.6.711,代碼行數:28,代碼來源:aggregation_rotatepic.aspx.cs

示例12: Invoke

        /// <summary>
        /// Executes the command logics.
        /// </summary>
        public override void Invoke()
        {
            //print request xml
            var doc = new XmlDocument();
            var stringWriter = new StringWriter();

            //get your document
            try
            {
                doc.LoadXml(this.document.Text);
            }
            catch (Exception)
            {
                return;
            }

            //create reader and writer
            var xmlReader = new XmlNodeReader(doc);

            //set formatting options
            var xmlWriter = new XmlTextWriter(stringWriter)
                                {
                                    Formatting = Formatting.Indented,
                                    Indentation = 3,
                                    IndentChar = ' '
                                };

            //write the document formatted
            xmlWriter.WriteNode(xmlReader, true);

            this.document.Text = stringWriter.ToString();
        }
開發者ID:Waltervondehans,項目名稱:NBi,代碼行數:35,代碼來源:AutoIndentCommand.cs

示例13: Create

		public object Create(object parent, object configContext, XmlNode section)
		{
			ILog _log = null;
			try
			{
				_log = LogManager.GetLogger(typeof(XmlConfigurator));
			}
			catch{}

			object settings = null;
			if (section == null) 
				return settings;

			XmlSerializer xmlSerializer = new XmlSerializer(typeof(FluorineSettings));
			XmlNodeReader reader = new XmlNodeReader(section);
			try
			{
				settings = xmlSerializer.Deserialize(reader);
			}
			catch(Exception ex)
			{
				if( _log != null && _log.IsErrorEnabled )
					_log.Error(ex.Message, ex);
			}
			finally
			{
				xmlSerializer = null;
			}
			return settings;
		}
開發者ID:ByteSempai,項目名稱:Ubiquitous,代碼行數:30,代碼來源:XmlConfigurator.cs

示例14: XmlPackage

 /// <summary>
 /// 從序列化的Xml文檔中還原對象
 /// </summary>
 public XmlPackage(XmlDocument xmlDoc)
 {
     XmlNodeReader reader = new XmlNodeReader(xmlDoc.DocumentElement);
     XmlSerializer ser = new XmlSerializer(typeof(XmlPackage));
     XmlPackage pkg = (XmlPackage)ser.Deserialize(reader);
     this.SetPackageDictionary(pkg.GetPackageDictionary());
 }
開發者ID:vbyte,項目名稱:fmq,代碼行數:10,代碼來源:XmlPackage.cs

示例15: Create

        public object Create( object parent, object configContext, XmlNode section )
        {
            XPathNavigator navigator = section.CreateNavigator();
            string typeName = ( string )navigator.Evaluate( "string(@type)" );

            if( string.IsNullOrEmpty( typeName ) )
                throw new ConfigurationErrorsException( string.Format( MISSING_TYPE_MSG, section.Name ), section );

            Type type = Type.GetType( typeName );
            if( type == null )
                throw new ConfigurationErrorsException( string.Format( NULL_TYPE_MSG, typeName, section.Name ), section );

            XmlSerializer serializer = new XmlSerializer( type );
            XmlNodeReader reader = new XmlNodeReader( section );

            try
            {
                return serializer.Deserialize( reader );
            }
            catch( Exception ex )
            {
                throw new ConfigurationErrorsException(
                    string.Format( FAILED_DESERIALIZE_MSG, typeName, section.Name, FormattedInnerExceptions( ex ) ),
                    ex, section );
            }
        }
開發者ID:ghostmonk,項目名稱:GhostmonkWeb,代碼行數:26,代碼來源:XmlSerializerConfigSectionHandler.cs


注:本文中的System.Xml.XmlNodeReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。