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


C# XmlTextReader.MoveToContent方法代码示例

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


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

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        AWSAuthConnection conn = new AWSAuthConnection(accessKey, secretKey);

          XmlTextReader r = new XmlTextReader(Request.InputStream);
          r.MoveToContent();
          string xml = r.ReadOuterXml();

          XmlDocument documentToSave = new XmlDocument();
          documentToSave.LoadXml(xml);

          SortedList metadata = new SortedList();
          metadata.Add("title", bucket);
          metadata.Add("Content-Type", "application/xml");
          S3Object titledObject =
           new S3Object(documentToSave.OuterXml, metadata);

          SortedList headers = new SortedList();
          headers.Add("Content-Type", "application/xml");
          headers.Add("x-amz-acl", "public-read");

          conn.put(bucket, documentKey, titledObject, headers);

          Response.Write("saved: " + documentToSave.OuterXml);
    }
开发者ID:isccarlosaguilar,项目名称:exosamples,代码行数:25,代码来源:save.aspx.cs

示例2: rss_update

    private void rss_update(object sender, EventArgs e)
    {
        int i;
        string title;
        int toggler = 1;
        try
        {
            led_line = "";
            reader = new XmlTextReader(url);
            using(reader)
            {
                reader.Read();
                reader.MoveToContent();
                i = 0;
                while(!reader.EOF)
                {
                    while(!reader.EOF && reader.Name != "item")
                        reader.Read();
                    while(!reader.EOF && reader.Name != "title")
                        reader.Read();
                    if(!reader.EOF)
                    {
                        title = reader.ReadString();
                        titles[i++] = title;
                        led_line += title+ " ";
                        if(toggler == 1)
                            led_line += "%r";
                        else
                            led_line += "%g";
                        toggler ^= 1;
                    }

                }
                num_titles = i;
            }

        }
        catch(Exception)
        {
            return;
        }
    }
开发者ID:elmo2k3,项目名称:mLedMatrix,代码行数:42,代码来源:RssPlugin.cs

示例3: parseXML

 private Dictionary<string, string> parseXML(string XML)
 {
     if (XML == string.Empty) return new Dictionary<string, string>(); // Catch empty response
     Dictionary<string, string> parameters = new Dictionary<string, string>();
     XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(XML));
     reader.MoveToContent();
     while (reader.Read())
     {
         reader.MoveToContent();
         parameters.Add(reader.Name,reader.ReadInnerXml().ToString());
     }
     return parameters;
 }
开发者ID:defcon8,项目名称:GNURender,代码行数:13,代码来源:xmlrpc.cs

示例4: FromXmlString

		public override void FromXmlString(string xmlString)
		{
			StringReader input = new StringReader(xmlString);
			XmlTextReader xmlTextReader = new XmlTextReader(input);
			this.class14_0 = (this.class14_1 = (this.class14_2 = (this.class14_3 = (this.class14_4 = (this.class14_5 = (this.class14_6 = (this.class14_7 = null)))))));
			while (true)
			{
				XmlNodeType xmlNodeType = xmlTextReader.MoveToContent();
				XmlNodeType xmlNodeType2 = xmlNodeType;
				switch (xmlNodeType2)
				{
				case XmlNodeType.None:
					return;
				case XmlNodeType.Element:
				{
					string name = xmlTextReader.Name;
					if (!this.method_15(xmlTextReader, name, "Modulus", ref this.class14_0) && !this.method_15(xmlTextReader, name, "Exponent", ref this.class14_1) && !this.method_15(xmlTextReader, name, "P", ref this.class14_2) && !this.method_15(xmlTextReader, name, "Q", ref this.class14_3) && !this.method_15(xmlTextReader, name, "DP", ref this.class14_4) && !this.method_15(xmlTextReader, name, "DQ", ref this.class14_5) && !this.method_15(xmlTextReader, name, "InverseQ", ref this.class14_6) && !this.method_15(xmlTextReader, name, "D", ref this.class14_7))
					{
						xmlTextReader.ReadString();
					}
					break;
				}
				default:
					if (xmlNodeType2 != XmlNodeType.EndElement)
					{
						goto Block_9;
					}
					xmlTextReader.ReadEndElement();
					break;
				}
			}
			Block_9:
			throw new ArgumentException();
		}
开发者ID:akordowski,项目名称:Source-Code-Nitriq,代码行数:34,代码来源:Class1.cs

示例5: xmlparse

    // pseudo SAX reader
    public static void xmlparse(string fname)
    {
        XmlReader reader = new XmlTextReader(fname);
        string line;

        urls    =       new ArrayList();
        int cnt  = 0;
        // http://msdn.microsoft.com/en-us/library/1z92b1d4.aspx
        // http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readsubtree.aspx
        while (reader.Read()) {
        if (reader.MoveToContent() == XmlNodeType.Element &&
            reader.Name == "formvals") {

            XmlReader inner = reader.ReadSubtree();
            StringDictionary myCol = new StringDictionary();
            while (inner.Read()) {

                if (inner.MoveToContent() == XmlNodeType.Element &&
                    inner.Name == "input") {

                    inner.MoveToFirstAttribute();
        // to avoid dependency on the attribute order, key them by the attribute name
        // amended with the unique count of the current input element.
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    inner.MoveToNextAttribute();
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    cnt++;
                }

                DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
                myCol.CopyTo(myArr, 0);

                for (int i = 0; i < myArr.Length; i++) {

                    try{

                        string inputNameRegExp = @"name\-(?<input>\d+)";
                        MatchCollection myMatchCollection =
                            Regex.Matches(myArr[i].Key.ToString(), inputNameRegExp );

                        foreach (Match myMatch in myMatchCollection) {

                            string pos =  myMatch.Groups["input"].Value.ToString();
                            // do not use StringDictionary for final formvals or you have your keyc converted to lower case.
                            formvals.Add(myCol[String.Format("name-{0}", pos)], myCol[String.Format("value-{0}", pos)]);

                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.ToString());
                    }

                }
                myCol.Clear();
            }
            foreach ( KeyValuePair<string, string> kvp in formvals )
                Console.WriteLine("formvals[ {0} ] = {1}", kvp.Key, kvp.Value);

            inner.Close();

        }
        if (reader.MoveToContent() == XmlNodeType.Element &&   reader.Name == "url") {
            line    =       reader.ReadString();
            urls.Add(line);
            Console.WriteLine(line);
        }
        }
    }
开发者ID:testpulse,项目名称:powershell_selenium,代码行数:68,代码来源:xparse.cs

示例6: LoadSets

    public static List<UrlMapSet> LoadSets()
    {
        List<UrlMapSet> sets = new List<UrlMapSet>();

        using (XmlReader reader = new XmlTextReader(new StreamReader(HttpContext.Current.Server.MapPath("~/Config/FileSets.xml"))))
        {
            reader.MoveToContent();
            while (reader.Read())
            {
                if ("set" == reader.Name)
                {
                    string setName = reader.GetAttribute("name");
                    UrlMapSet UrlMapSet = new UrlMapSet();
                    UrlMapSet.Name = setName;

                    while (reader.Read())
                    {
                        if ("url" == reader.Name)
                        {
                            string urlName = reader.GetAttribute("name");
                            string url = reader.ReadElementContentAsString();
                            UrlMapSet.Urls.Add(new UrlMap(urlName, url));
                        }
                        else if ("set" == reader.Name)
                            break;
                    }

                    sets.Add(UrlMapSet);
                }
            }
        }

        return sets;
    }
开发者ID:foxvirtuous,项目名称:MVB2C,代码行数:34,代码来源:CombineScripts.cs

示例7: LoadSettings

    public static CamConfigData[] LoadSettings(string vsSettingsFile)
    {

        List<CamConfigData> data = new List<CamConfigData>();
        // check file existance
        if (File.Exists(vsSettingsFile))
        {
            //  VsSplasher.Status = "Load setting...";

            FileStream fs = null;
            XmlTextReader xmlIn = null;


            // open file
            fs = new FileStream(vsSettingsFile, FileMode.Open, FileAccess.Read);
            // create XML reader
            xmlIn = new XmlTextReader(fs);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            // check for main node
            if (xmlIn.Name != "Cameras")
                throw new ApplicationException("");

            xmlIn.Read();
            if (xmlIn.NodeType == XmlNodeType.EndElement)
                xmlIn.Read();

            CamConfigData obj;

            while (xmlIn.Name == "Camera")
            {
                obj = new CamConfigData();

                obj.id = Convert.ToInt32(xmlIn.GetAttribute("id"));
                obj.name = xmlIn.GetAttribute("name");
                obj.desc = xmlIn.GetAttribute("desc");

                obj.run = Convert.ToBoolean(xmlIn.GetAttribute("run"));
                obj.analyse = Convert.ToBoolean(xmlIn.GetAttribute("analyse"));
                obj.record = Convert.ToBoolean(xmlIn.GetAttribute("record"));
                obj.events = Convert.ToBoolean(xmlIn.GetAttribute("event"));
                obj.data = Convert.ToBoolean(xmlIn.GetAttribute("data"));

                obj.provider = xmlIn.GetAttribute("provider");
                obj.source = xmlIn.GetAttribute("source");
                obj.analyzer = xmlIn.GetAttribute("analyzer");

                obj.ThresholdAlpha = Convert.ToInt32(xmlIn.GetAttribute("ThresholdAlpha"));
                obj.ThresholdSigma = Convert.ToInt32(xmlIn.GetAttribute("ThresholdSigma"));
                obj.endcoder = xmlIn.GetAttribute("encoder");

                obj.ImageWidth = Convert.ToInt32(xmlIn.GetAttribute("ImageWidth"));
                obj.ImageHeight = Convert.ToInt32(xmlIn.GetAttribute("ImageHeight"));

                obj.CodecsName = xmlIn.GetAttribute("CodecsName");
                obj.Quality = Convert.ToInt32(xmlIn.GetAttribute("Quality"));

                data.Add(obj);

                xmlIn.Read();
                if (xmlIn.NodeType == XmlNodeType.EndElement)
                    xmlIn.Read();
            }

            // close file
            xmlIn.Close();
            fs.Close();

            return data.ToArray();
        }
        else
        {
            return data.ToArray();
        }
    }
开发者ID:tdhieu,项目名称:openvss,代码行数:77,代码来源:CamConfigData.cs

示例8: parseXML

        public void parseXML(string strPath)
        {
            try {
                XmlTextReader reader = new XmlTextReader (strPath);
                reader.Read ();
                Console.WriteLine ("--- Dateianfang ---");
                Console.WriteLine (reader.ReadToEnd ());
                Console.WriteLine ("--- Dateiende -----");

                Console.WriteLine (reader.NodeType); // It prints "XmlDeclaration"

                reader.MoveToContent ();
                Console.WriteLine (reader.NodeType); // It prints "Element"
                Console.WriteLine (reader.Name); // "rss"
                Console.WriteLine (reader.GetAttribute ("version")); // Maybe "0.92"

                // proceed content until we reach "item" element
                while (!reader.EOF && reader.Name != "item")
                    reader.Read ();

                reader.Read (); // Move from "item" to "title"
                while (reader.NodeType == XmlNodeType.Whitespace)
                    reader.Read ();
                Console.WriteLine ("Title : " + reader.ReadString ());

                reader.Read (); // from "</title>" to whitespace
                reader.Read (); // from whitespace to <link>
                Console.WriteLine ("Link  : " + reader.ReadString ());

                reader.Read (); // from "</link>" to whitespace
                reader.Read (); // from whitespace to <pubDate>
                Console.WriteLine ("Date  : " + reader.ReadString ());

                reader.Read (); // from "</pubDate>" to whitespace
                reader.Read (); // from whitespace to <description>
                Console.WriteLine ("Description : " + reader.ReadString ());

            }

            // Datei nicht gefunden

            catch (FileNotFoundException ex) {
                Console.WriteLine (ex.Message);
            }

            // Verzeichnis existiert nicht

            catch (DirectoryNotFoundException ex) {
                Console.WriteLine (ex.Message);
            }

            // Pfadangabe war 'null'

            catch (ArgumentNullException ex) {
                Console.WriteLine (ex.Message);
            }

            // Pfadangabe war leer ("")

            catch (ArgumentException ex) {
                Console.WriteLine (ex.Message);
            }

            // allgemeine Exception

            catch (Exception ex) {
                Console.WriteLine (ex.Message);
            }
        }
开发者ID:rest1014,项目名称:SupplyChain,代码行数:69,代码来源:XMLParser.cs

示例9: ImportStrategy

    public static bool ImportStrategy(string fileName)
    {
        FileStream fileStream = null;
        bool bRet = false;
        try
        {
            int buffSize = 512;
            byte[] automationData;
            fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read);
            XmlTextReader reader = new XmlTextReader(fileStream);
            
            reader.MoveToElement();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("Strategy"))
                {                    
                    //读Name
                    reader.Read();
                    reader.MoveToContent();
                    string name = reader.ReadElementContentAsString();
                    //读Comment
                    reader.Read();
                    reader.MoveToContent();
                    string comment = reader.ReadElementContentAsString();

                    Strategy strategyToAdd = new Strategy();
                    //读Event
                    reader.Read();
                    reader.MoveToContent();
                    strategyToAdd.Event = (FSEyeEvent)reader.ReadElementContentAsInt();
                    //读Automation
                    reader.Read();
                    reader.MoveToContent();                    
                    int realLength = 0;
                    automationData = new byte[buffSize];
                    byte[] tempBuff = new byte[buffSize];
                    int readCount = reader.ReadElementContentAsBinHex(tempBuff, 0, buffSize);
                    Array.Copy(tempBuff, 0, automationData, realLength, readCount);
                    realLength +=  readCount;
                    while (tempBuff.Length == readCount)
                    {
                        Array.Resize<byte>(ref automationData, automationData.Length + buffSize);
                        readCount = reader.ReadElementContentAsBinHex(tempBuff, 0, buffSize);
                        Array.Copy(tempBuff, 0, automationData, realLength, readCount);
                        realLength += readCount;                        
                    }
                    Array.Resize<byte>(ref automationData, realLength);
                    strategyToAdd.Automation = AdminServer.TheInstance.AutomationManager.Load(automationData);
                    //读Enable
                    reader.Read();
                    reader.MoveToContent();
                    strategyToAdd.Enabled = reader.ReadElementContentAsInt() == 1 ? true : false;                    
                    AdminServer.TheInstance.StrategyManager.Add(strategyToAdd, name, comment);
                }
            }
            bRet = true;
        }
        catch (Exception)
        {
            bRet = false;
        }
        finally
        {
            if (fileStream != null) fileStream.Close();
        }
        return bRet;
    }    
开发者ID:viticm,项目名称:pap2,代码行数:67,代码来源:WebUtil.cs

示例10: ImportScheduledTask

 public static bool ImportScheduledTask(string fileName)
 {
     FileStream fileStream = null;
     bool bRet = false;
     try
     {
         int buffSize = 512;
         byte[] taskData;
         fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read);
         XmlTextReader reader = new XmlTextReader(fileStream);
                     
         reader.MoveToElement();
         
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("Task"))
             {
                 //读Name
                 reader.Read();                    
                 reader.MoveToContent();
                 string name = reader.ReadElementContentAsString();
                 //读Comment
                 reader.Read();
                 reader.MoveToContent();
                 string comment = reader.ReadElementContentAsString();
                 //读Data
                 reader.Read();
                 reader.MoveToContent();
                 
                 int realLength = 0;
                 taskData = new byte[buffSize];                    
                 byte[] tempBuff = new byte[buffSize];
                 int readCount = reader.ReadElementContentAsBinHex(tempBuff, 0, buffSize);
                 Array.Copy(tempBuff, 0, taskData, realLength, readCount);
                 realLength += readCount;
                 while (tempBuff.Length == readCount)
                 {
                     Array.Resize<byte>(ref taskData, taskData.Length + buffSize);
                     readCount = reader.ReadElementContentAsBinHex(tempBuff, 0, buffSize);
                     Array.Copy(tempBuff, 0, taskData, realLength, readCount);
                     realLength += readCount;
                 }
                 Array.Resize<byte>(ref taskData, realLength);
                 MemoryStream taskDataStream = new MemoryStream(taskData);
                 IFormatter formatter = new BinaryFormatter();
                 IScheduledTask task = (IScheduledTask)formatter.Deserialize(taskDataStream);
                 AdminServer.TheInstance.ScheduledTaskManager.Add(task, name, comment);
             }
         }
         bRet = true;
     }
     catch (Exception)
     {
         bRet = false;
     }
     finally
     {
         if (fileStream != null) fileStream.Close();
     }
     return bRet;
 }
开发者ID:viticm,项目名称:pap2,代码行数:61,代码来源:WebUtil.cs

示例11: LoadSettings

    public bool LoadSettings(string vsSettingsFile)
    {

        // check file existance
        if (File.Exists(vsSettingsFile))
        {
            //  VsSplasher.Status = "Load setting...";

            FileStream fs = null;
            XmlTextReader xmlIn = null;


            // open file
            fs = new FileStream(vsSettingsFile, FileMode.Open,FileAccess.Read);
            // create XML reader
            xmlIn = new XmlTextReader(fs);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            // check for main node
            if (xmlIn.Name != "appSettings")
                throw new ApplicationException("");

            xmlIn.Read();
            if (xmlIn.NodeType == XmlNodeType.EndElement)
                xmlIn.Read();

            while (xmlIn.Name == "add")
            {
                data.Add(xmlIn.GetAttribute("key"), xmlIn.GetAttribute("value"));


                xmlIn.Read();
                if (xmlIn.NodeType == XmlNodeType.EndElement)
                    xmlIn.Read();
            }

            // close file
            xmlIn.Close();
            fs.Close();
            return true;
        }
        else
        {
            return false;
        }
    }
开发者ID:tdhieu,项目名称:openvss,代码行数:48,代码来源:WebConfigData.cs


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