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


C# XmlTextReader.MoveToFirstAttribute方法代码示例

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


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

示例1: OpenXML_Zefania_XML_Bible_Markup_Language

        public OpenXML_Zefania_XML_Bible_Markup_Language(string fileLocation, bible_data.BookManipulator manipulator)
        {
            _fileLocation = fileLocation;
            _reader = new XmlTextReader(_fileLocation);
            _bible = manipulator;

            // Create an XmlReader for <format>Zefania XML Bible Markup Language</format>
            using (_reader)
            {
                _reader.ReadToFollowing("title");
                String title = _reader.ReadElementContentAsString();
                _bible.SetVersion(title);

                String book;
                int verseNumber;
                int chapterNumber;
                string verseString;

                while (_reader.ReadToFollowing("BIBLEBOOK")) // read each book name
                {
                    _reader.MoveToAttribute(1);
                    book = _reader.Value;
                    _reader.ReadToFollowing("CHAPTER");
                    while (_reader.Name == "CHAPTER") // read each chapter
                    {
                        _reader.MoveToFirstAttribute();
                        chapterNumber = Convert.ToInt32(_reader.Value);

                        _reader.ReadToFollowing("VERS");
                        while (_reader.Name == "VERS") // read each verse
                        {
                            _reader.MoveToFirstAttribute();
                            verseNumber = Convert.ToInt32(_reader.Value);
                            _reader.Read();
                            verseString = _reader.Value;

                            sendToDataTree(book, verseNumber, chapterNumber, verseString);

                            _reader.Read();
                            _reader.Read();
                            _reader.Read();
                        }//end verse while

                        _reader.Read();
                        _reader.Read();
                    } //end chapter while
                } // end book while
            } //end using statement
        }
开发者ID:sorvis,项目名称:Fast-Script,代码行数:49,代码来源:openXML_Zefania_XML_Bible_Markup_Language.cs

示例2: readXml

        public void readXml()
        {
            using (XmlTextReader reader = new XmlTextReader("dump.xml"))
            {
                reader.ReadToFollowing("range");
                while (reader.EOF == false)
                {

                    reader.MoveToFirstAttribute();
                    rangeNameList.Add(reader.Value);
                    reader.MoveToNextAttribute();
                    string temp = (reader.Value);
                    rangeNameList.Add(temp);
                    rangeStartList.Add(Int32.Parse(reader.Value, System.Globalization.NumberStyles.HexNumber));
                    reader.MoveToNextAttribute();
                    temp = (reader.Value);
                    rangeNameList.Add(temp);
                    int temp1 = (Int32.Parse(reader.Value, System.Globalization.NumberStyles.HexNumber));
                    int temp2 = rangeStartList[rangeStartList.Count-1];
                    rangeLengthList.Add(temp1-temp2);

                    reader.ReadToFollowing("range");
                }

            }
        }
开发者ID:Merp,项目名称:SharpTune,代码行数:26,代码来源:DumpXML.cs

示例3: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            XmlTextReader tr =
                new XmlTextReader(@"D:\MS.Net\CSharp\XMLParser\XMLParser\Emp.xml");
            while (tr.Read())
            {
                //Check if it is a start tag
                if (tr.NodeType == XmlNodeType.Element)
                {
                    listBox1.Items.Add(tr.Name);
                    if (tr.HasAttributes)
                    {
                        tr.MoveToFirstAttribute();
                        string str = tr.Name;
                        str += " = ";
                        str += tr.Value;
                        listBox1.Items.Add(str);
                    }
                    if (tr.MoveToNextAttribute())
                    {

                        string str = tr.Name;
                        str += " = ";
                        str += tr.Value;
                        listBox1.Items.Add(str);
                    }
                }
                if (tr.NodeType == XmlNodeType.Text)
                {
                    listBox1.Items.Add(tr.Value);
                }

            }
        }
开发者ID:prijuly2000,项目名称:Dot-Net,代码行数:34,代码来源:Form2.cs

示例4: EnumerateAttributes

        private int EnumerateAttributes(string elementStartTag, Action<int, int, string> onAttributeSpotted)
        {
            bool selfClosed = (elementStartTag.EndsWith("/>", StringComparison.Ordinal));
            string xmlDocString = elementStartTag;
            if (!selfClosed)
            {
                xmlDocString = elementStartTag.Substring(0, elementStartTag.Length-1) + "/>" ;
            }

            XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlDocString));

            xmlReader.Namespaces = false;
            xmlReader.Read();

            bool hasMoreAttributes = xmlReader.MoveToFirstAttribute();
            while (hasMoreAttributes)
            {
                onAttributeSpotted(xmlReader.LineNumber, xmlReader.LinePosition, xmlReader.Name);
                hasMoreAttributes = xmlReader.MoveToNextAttribute();
            }

            int lastCharacter = elementStartTag.Length;
            if (selfClosed)
            {
                lastCharacter--;
            }
            return lastCharacter;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:28,代码来源:XmlAttributePreservationDict.cs

示例5: LoadVideoFile

 public List<string> LoadVideoFile(string file)
 {
     List<string> videos = new List<string>();
     using (XmlReader reader = new XmlTextReader(file))
     {
         do
         {
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element:
                     reader.MoveToFirstAttribute();
                     title.Add(reader.Value);
                     reader.MoveToNextAttribute();
                     author.Add(reader.Value);
                     reader.MoveToNextAttribute();
                     videos.Add(reader.Value);
                     WriteXNBVideoData(reader.Value);
                     break;
             }
         } while (reader.Read());
     }
     title.RemoveAt(0);
     author.RemoveAt(0);
     videos.RemoveAt(0);
     return videos;
 }
开发者ID:stpettersens,项目名称:Presenter,代码行数:26,代码来源:VideoLoader.cs

示例6: GBXMLContainer

 public GBXMLContainer(XmlTextReader reader)
 {
     while (reader.NodeType != XmlNodeType.Element)
     {
         reader.Read();
     }
     name = reader.Name;
     // check if the element has any attributes
     if (reader.HasAttributes) {
         // move to the first attribute
         reader.MoveToFirstAttribute ();
         for (int i = 0; i < reader.AttributeCount; i++) {
             // read the current attribute
             reader.MoveToAttribute (i);
             if (AttributesToChildren)
             {
                 GBXMLContainer newChild = new GBXMLContainer();
                 newChild.name = reader.Name;
                 newChild.textValue = reader.Value;
                 children.Add(newChild);
             }
             else
             {
                 attributes [reader.Name] = reader.Value;
             }
         }
     }
     reader.MoveToContent ();
     bool EndReached = reader.IsEmptyElement;
     while (!EndReached && reader.Read()) {
         switch (reader.NodeType) {
         case XmlNodeType.Element:
             GBXMLContainer newChild = new GBXMLContainer (reader);
             children.Add (newChild);
             break;
         case XmlNodeType.Text:
             textValue = reader.Value;
             break;
         case XmlNodeType.XmlDeclaration:
         case XmlNodeType.ProcessingInstruction:
             break;
         case XmlNodeType.Comment:
             break;
         case XmlNodeType.EndElement:
             EndReached = true;
             break;
         }
     }
 }
开发者ID:remy22,项目名称:GameBox,代码行数:49,代码来源:GBXMLContainer.cs

示例7: readXmlContent

 private void readXmlContent()
 {
     XmlTextReader reader = new XmlTextReader(".\\configurationFiles\\FilePaths.xml");
     String osName = externalCode.OSVersionInfo.Name.Split(new char[]{' '})[0].ToLower();
     while (reader.ReadToFollowing("os"))
     {
         reader.MoveToFirstAttribute();
         if (reader.Value.Equals(osName))
         {
             reader.ReadToFollowing("fileName");
             this.fileName = reader.ReadElementContentAsString();
             reader.ReadToFollowing("environmentVariable");
             this.environmentVariable = reader.ReadElementContentAsString();
             reader.ReadToFollowing("path");
             this.path = reader.ReadElementContentAsString();
             break;
         }
     }
 }
开发者ID:thomasdewaelheyns,项目名称:hostWin,代码行数:19,代码来源:WindowsFilePathReader.cs

示例8: ReadPreservationInfo

 internal void ReadPreservationInfo(string elementStartTag)
 {
     XmlTextReader xmlTextReader = new XmlTextReader((TextReader)new StringReader(elementStartTag));
     WhitespaceTrackingTextReader trackingTextReader = new WhitespaceTrackingTextReader((TextReader)new StringReader(elementStartTag));
     xmlTextReader.Namespaces = false;
     xmlTextReader.Read();
     for (bool flag = xmlTextReader.MoveToFirstAttribute(); flag; flag = xmlTextReader.MoveToNextAttribute())
     {
         this.orderedAttributes.Add(xmlTextReader.Name);
         if (trackingTextReader.ReadToPosition(xmlTextReader.LineNumber, xmlTextReader.LinePosition))
             this.leadingSpaces.Add(xmlTextReader.Name, trackingTextReader.PrecedingWhitespace);
     }
     int length = elementStartTag.Length;
     if (elementStartTag.EndsWith("/>", StringComparison.Ordinal))
         --length;
     if (!trackingTextReader.ReadToPosition(length))
         return;
     this.leadingSpaces.Add(string.Empty, trackingTextReader.PrecedingWhitespace);
 }
开发者ID:micahlmartin,项目名称:XmlTransformer,代码行数:19,代码来源:XmlAttributePreservationDict.cs

示例9: addd_ata

        public void addd_ata()
        {
            //  XmlTextReader reader1 = new XmlTextReader(folderBrowserDialog2.SelectedPath + "\\" + textBox2.Text + ".xml");
            //XmlTextReader reader = new XmlTextReader(folderBrowserDialog1.SelectedPath+"\\"+textBox1.Text+".xml");
            //XmlTextReader reader = new XmlTextReader("\\\\voting-1\\test-1\\shendy1.xml");
            //XmlTextReader reader1 = new XmlTextReader("\\\\voting-1\\test-1\\shendy1.xml");
            XmlTextReader reader = new XmlTextReader("c:\\users\\ali\\desktop\\whats your name.xml");
            XmlTextReader reader1 = new XmlTextReader("c:\\users\\ali\\desktop\\whats your name.xml");

            for (int i = 0; i <= question_no; i++)
            {
                reader.ReadToFollowing("Question");
            }
            if (!reader.EOF)
            {

                reader.MoveToAttribute(1);
                questions[question_no].title = reader.Value;

                reader.MoveToAttribute(5);
                questions[question_no].choices_no = reader.Value;
                choices_no1 = Convert.ToInt32(questions[question_no].choices_no);
                //reader.ReadToFollowing("Data");
                for (int i = 0; i < choices_no1; ++i)
                {

                    reader.ReadToFollowing("Data");
                    reader.MoveToFirstAttribute();
                    questions[question_no].choices.Add(reader.Value);
                    reader.MoveToContent();

                    questions[question_no].values.Add(reader.ReadElementContentAsInt());

                }

            }
            for (int i = 0; i <= question_no; i++)
            {
                reader1.ReadToFollowing("Question");
            }
            if (!reader1.EOF)
            {

                // reader1.ReadToFollowing("Data");

                for (int i = 0; i < choices_no1; i++)
                {
                    reader1.ReadToFollowing("Data");

                    reader1.MoveToContent();

                    questions[question_no].values[i] = (questions[question_no].values[i] + reader1.ReadElementContentAsInt());

                }

                player.add_slide(ref question_no, ref questions, ref openFileDialog1);
                player.add_title(ref questions, ref question_no);
                player.add_choices(ref questions, ref question_no, ref choices_no1);
                player.add_chart(ref questions, ref question_no, ref choices_no1, ref colorDialog1, ref data_format, ref bar_colors, ref fontDialog1);
                player.start_show(ref question_no);
                question_no++;

            }

            reader.Close();
            reader1.Close();
            player.objApp.ActivePresentation.Save();
        }
开发者ID:AliHosny,项目名称:Vote-MZ,代码行数:68,代码来源:Form1.cs

示例10: ParseConfig

        public int ParseConfig(string configFile, bool bDeep = false)
        {
            //
            // Consume XML to create the XFSEntity objects.
            // if bDeep is false, then ONLY do this object.
            // if bDeep is true, then also do recursive objects.
            XmlTextReader reader = null;

            int rc = -1;
            string connectString = XTRMObject.getDictionaryEntry("TaskConnectString");
            string outerXML;
            int lElementType = 0;
            XDictionaryLoader myDictionaryLoader = new XDictionaryLoader();
            Dictionary<String, String> elementAttributes;
            entities.Clear();
            try
            {
                // Load the reader with the data file and ignore all white space nodes.
                reader = new XmlTextReader(configFile);
                reader.WhitespaceHandling = WhitespaceHandling.None;
                // Parse the file and display each of the nodes.
                bool bResult = reader.Read();
                while (bResult)
                {
                    bool bProcessed = false;
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            string elementName = reader.Name;
                            switch (elementName.ToUpper())
                            {
                                case "XFSENTITY":
                                    outerXML = reader.ReadOuterXml();
                                    XTRMFSEntity thisEntity = (XTRMFSEntity)XTRMFSEntity.consumeXML(outerXML, 1, true);
                                    entities.Add(thisEntity);
                                    bProcessed = true;
                                    break;
                            }
                            if (!bProcessed)
                            {
                                // May wish to get all the  attributes here for new elements!
                                elementAttributes = new Dictionary<String, String>();
                                if (reader.HasAttributes)
                                {
                                    reader.MoveToFirstAttribute();
                                    for (int i = 0; i < reader.AttributeCount; i++)
                                    {
                                        //reader.GetAttribute(i);
                                        elementAttributes.Add(reader.Name, reader.Value);
                                        reader.MoveToNextAttribute();
                                    }
                                    if (elementAttributes.ContainsKey("Tag"))
                                    {
                                        agentTag = elementAttributes["Tag"];
                                    }
                                    if (elementAttributes.ContainsKey("Source"))
                                    {
                                        agentSource = elementAttributes["Source"];
                                    }
                                    if (elementAttributes.ContainsKey("User"))
                                    {
                                        agentUser = elementAttributes["User"];
                                    }
                                    if (elementAttributes.ContainsKey("EventPath"))
                                    {
                                        agentEventPath = elementAttributes["EventPath"];
                                    }
                                    reader.MoveToElement();
                                }
                                // Need to see if we are interested in this element!
                                //string elementName = reader.Name;
                                switch (elementName.ToUpper())
                                {
                                    case "XFILEAGENTCONFIG":
                                        // Advance into Elements!
                                        reader.MoveToContent();
                                        bResult = reader.Read();
                                        break;
                                    default:
                                        bResult = reader.Read();
                                        break;
                                }
                            }
                            break;
                        case XmlNodeType.XmlDeclaration:
                        case XmlNodeType.ProcessingInstruction:
                            //writer.WriteProcessingInstruction(reader.Name, reader.Value);
                            bResult = reader.Read();
                            break;
                        case XmlNodeType.Comment:
                            //writer.WriteComment(reader.Value);
                            bResult = reader.Read();
                            break;
                        case XmlNodeType.EndElement:
                            //writer.WriteFullEndElement();
                            bResult = reader.Read();
                            break;
                        case XmlNodeType.Text:
                            //Console.Write(reader.Value);
                            switch (lElementType)
//.........这里部分代码省略.........
开发者ID:cs180011,项目名称:XTRM,代码行数:101,代码来源:XTRMFileAgent.cs

示例11: Deserialize

        /// <summary>
        /// Load a query from a file
        /// </summary>
        public static Query Deserialize(string outfile)
        {
            List<OperatorParams> ops = new List<OperatorParams>();
            int idTopOperator = -1;
            using (XmlTextReader reader = new XmlTextReader(outfile))
            {
                reader.Read();
                idTopOperator = Int32.Parse(reader.GetAttribute(XMLTOPID));
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        ops.Add(new OperatorParams());
                        ops[ops.Count - 1].opName = reader.Name;
                        ops[ops.Count - 1].opParams = new string[reader.AttributeCount];
                        reader.MoveToFirstAttribute();
                        int i = 0;
                        do
                        {
                            if (reader.Name == XMLINPUTID)
                            {
                                ops[ops.Count - 1].rginputs = new int[1];
                                ops[ops.Count - 1].rginputs[0] = Int32.Parse(reader.Value);
                            }
                            else if (reader.Name == XMLLEFTINPUTID)
                            {
                                if (ops[ops.Count - 1].rginputs == null)
                                    ops[ops.Count - 1].rginputs = new int[2];
                                ops[ops.Count - 1].rginputs[0] = Int32.Parse(reader.Value);
                            }
                            else if (reader.Name == XMLRIGHTINPUTID)
                            {
                                if (ops[ops.Count - 1].rginputs == null)
                                    ops[ops.Count - 1].rginputs = new int[2];
                                ops[ops.Count - 1].rginputs[1] = Int32.Parse(reader.Value);
                            }
                            else if (reader.Name == XMLINPUTCOUNT)
                                ops[ops.Count - 1].rginputs = new int[Int32.Parse(reader.Value)];
                            else if (ops[ops.Count-1].rginputs != null)
                            {
                                //Check to see if this is an expected input number
                                for (int j = 0; j < ops[ops.Count - 1].rginputs.Length; j++)
                                {
                                    if (reader.Name == string.Format("{0}{1}", XMLINPUTID, j))
                                        ops[ops.Count - 1].rginputs[j] = Int32.Parse(reader.Value);
                                }
                            }

                            ops[ops.Count - 1].opParams[i] =
                                string.Format("{0}={1}", reader.Name, reader.Value);
                            i++;
                        } while (reader.MoveToNextAttribute());
                    }
                }

                reader.Close();
            }

            //Now, build the query plan
            return BuildQueryPlan(ops, idTopOperator);
        }
开发者ID:ptucker,项目名称:WhitStream,代码行数:64,代码来源:Query.cs

示例12: TestXmlReader

 private static void TestXmlReader()
 {
     using (var fileStream = File.OpenRead(Path.Combine("save", "test.xml")))
     {
         using (var xmlTextReader = new XmlTextReader(fileStream))
         {
             while (xmlTextReader.Read())
             {
                 if (xmlTextReader.NodeType != XmlNodeType.Element) continue;
                 if (xmlTextReader.LocalName != "contents") continue;
                 xmlTextReader.MoveToFirstAttribute();
                 if (xmlTextReader.Value != "question") continue;
                 xmlTextReader.Read();
                 Console.WriteLine(xmlTextReader.Value);
             }
         }
     }
 }
开发者ID:RavingRabbit,项目名称:Labs,代码行数:18,代码来源:Program.cs

示例13: button3_Click

        private void button3_Click(object sender, EventArgs e)
        {
            XmlTextReader tr = new XmlTextReader(@"D:\nt-pritz\MS.NET\MS FRAMEWORK\CLASS DEMO\WindowsFormsApplication2\WindowsFormsApplication2\XMLFile1.xml");
            while (tr.Read())
            {
                if(tr.NodeType==XmlNodeType.Element)
                    listBox2.Items.Add(tr.Name);

                if (tr.NodeType == XmlNodeType.Text)
                    listBox2.Items.Add(tr.Value);

                if (tr.NodeType == XmlNodeType.Element)
                {
                    //listBox2.Items.Add(tr.Name);
                    if (tr.HasAttributes)
                    {
                        tr.MoveToFirstAttribute();
                        string str = tr.Name;
                        str += " : ";
                        str += tr.Value;
                        listBox2.Items.Add(str);
                    }
                    if (tr.MoveToNextAttribute())
                    {
                        string str = tr.Name;
                        str += " : ";
                        str += tr.Value;
                        listBox2.Items.Add(str);
                    }
                    if (tr.NodeType == XmlNodeType.Text)
                    {
                        listBox2.Items.Add(tr.Value);
                    }
                }
            }
        }
开发者ID:prijuly2000,项目名称:Dot-Net,代码行数:36,代码来源:Form1.cs

示例14: ExpandEntity

		public void ExpandEntity ()
		{
			string intSubset = "<!ELEMENT root (#PCDATA)><!ATTLIST root foo CDATA 'foo-def' bar CDATA 'bar-def'><!ENTITY ent 'entity string'>";
			string dtd = "<!DOCTYPE root [" + intSubset + "]>";
			string xml = dtd + "<root foo='&ent;' bar='internal &ent; value'>&ent;</root>";
			XmlTextReader dvr = new XmlTextReader (xml, XmlNodeType.Document, null);
			dvr.EntityHandling = EntityHandling.ExpandEntities;
			dvr.Read ();	// DTD
			dvr.Read ();
			AssertEquals (XmlNodeType.Element, dvr.NodeType);
			AssertEquals ("root", dvr.Name);
			Assert (dvr.MoveToFirstAttribute ());
			AssertEquals ("foo", dvr.Name);
			AssertEquals ("entity string", dvr.Value);
			Assert (dvr.MoveToNextAttribute ());
			AssertEquals ("bar", dvr.Name);
			AssertEquals ("internal entity string value", dvr.Value);
			AssertEquals ("entity string", dvr.ReadString ());
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:19,代码来源:XmlTextReaderTests.cs

示例15: QuoteChar

		public void QuoteChar ()
		{
			string xml = @"<a value='hello &amp; world' value2="""" />";
			XmlReader xmlReader =
				new XmlTextReader (new StringReader (xml));
			xmlReader.Read ();
			xmlReader.MoveToFirstAttribute ();
			AssertEquals ("First", '\'', xmlReader.QuoteChar);
			xmlReader.MoveToNextAttribute ();
			AssertEquals ("Next", '"', xmlReader.QuoteChar);
			xmlReader.MoveToFirstAttribute ();
			AssertEquals ("First.Again", '\'', xmlReader.QuoteChar);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:13,代码来源:XmlTextReaderTests.cs


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