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


C# XmlReader.MoveToElement方法代码示例

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


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

示例1: ParseColorAttributes

        public static ColorEx ParseColorAttributes(XmlReader r)
        {
            float R = 0;
            float G = 0;
            float B = 0;

            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                    case "R":
                        R = float.Parse(r.Value);
                        break;
                    case "G":
                        G = float.Parse(r.Value);
                        break;
                    case "B":
                        B = float.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            r.MoveToElement(); //Moves the reader back to the element node.
            if (R > 1 || G > 1 || B > 1)
            {
                R = R / 255;
                G = G / 255;
                B = B / 255;
            }
            return new ColorEx(R, G, B);
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:35,代码来源:XmlHelperClass.cs

示例2: ReadContent

		public static string ReadContent(XmlReader xr)
		{
			string rlt;
			if (xr.NodeType != XmlNodeType.Element)
			{
				xr.MoveToElement();
			}
			rlt = xr.ReadString();
			xr.MoveToElement();
			return rlt;
		}
开发者ID:mind0n,项目名称:hive,代码行数:11,代码来源:CodgenCore.cs

示例3: ParseQuaternion

        public static Quaternion ParseQuaternion(XmlReader r)
        {
            float w = 0;
            float x = 0;
            float y = 0;
            float z = 0;

            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {

                    case "w":
                        w = float.Parse(r.Value);
                        break;
                    case "x":
                        x = float.Parse(r.Value);
                        break;
                    case "y":
                        y = float.Parse(r.Value);
                        break;
                    case "z":
                        z = float.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            return new Quaternion(w, x, y, z);
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:33,代码来源:XmlHelperClass.cs

示例4: ReadXml

        public static KeyValuePair<string, Property> ReadXml(XmlReader reader)
        {
            var key = reader.GetAttribute("Key");
            var type = reader.GetAttribute("Type");

            reader.MoveToElement();
            reader.ReadStartElement("PropertyEntry");
            Property value = null;
            try
            {
                var t = Type.GetType(type);
                value = (Property)GetSerializer(t).Deserialize(reader);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Deserialization failed: " + ex.Message);
                Console.WriteLine("Property Key: " + key);
                Console.WriteLine("Property Type Qualified Name: " + type);
                Console.WriteLine("Stacktrace: " + ex.StackTrace);
            }

            reader.ReadEndElement();
            reader.MoveToContent();
            if (value == null)
                throw new Exception();
            return new KeyValuePair<string, Property>(key, value);
        }
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:27,代码来源:PropertyEntryMultiSerializer.cs

示例5: ReadObject

 public override object ReadObject(XmlReader reader)
 {
     OneWayAttachmentRequest OneWayAttachmentRequestField = null;
     if (IsParentStartElement(reader, false, true))
     {
         OneWayAttachmentRequestField = new OneWayAttachmentRequest();
         OneWayAttachmentRequestField.AnyAttr = ReadAnyAttribute(reader);
         reader.Read();
         if (IsChildStartElement(reader, "Param", true, true))
         {
             reader.Read();
             if (IsAttribute(reader, "href"))
             {
                 string contentID;
                 contentID = reader.Value;
                 reader.MoveToElement();
                 reader.ReadStartElement("Include", "http://www.w3.org/2004/08/xop/include");
                 reader.ReadEndElement();
                 OneWayAttachmentRequestField.Param = GetBodyPartContent(contentID, BodyParts);
             }
             else
             {
                 OneWayAttachmentRequestField.Param = Convert.FromBase64String(reader.ReadString());
                 reader.ReadEndElement();
             }
         }
         OneWayAttachmentRequestField.Any = ReadAnyElement(reader, false);
         reader.ReadEndElement();
     }
     return OneWayAttachmentRequestField;
 }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:31,代码来源:AttachmentService.cs

示例6: CreateResponseException

 public static Exception CreateResponseException(XmlReader reader)
 {
     if (reader == null)
     throw new ArgumentNullException("reader");
       reader.MoveToElement();
       if (!reader.ReadToDescendant("err"))
     throw new XmlException("No error element found in XML");
       int code = 0;
       string message = (string) null;
       while (reader.MoveToNextAttribute())
       {
     if (reader.LocalName == "code")
     {
       try
       {
     code = int.Parse(reader.Value, NumberStyles.Any, (IFormatProvider) NumberFormatInfo.InvariantInfo);
       }
       catch (FormatException ex)
       {
     throw new FlickrException("Invalid value found in code attribute. Value '" + (object) code + "' is not an integer");
       }
     }
     else if (reader.LocalName == "msg")
       message = reader.Value;
       }
       return (Exception) ExceptionHandler.CreateException(code, message);
 }
开发者ID:rmck,项目名称:FlickrNet,代码行数:27,代码来源:ExceptionHandler.cs

示例7: AttributeAssignmentElementReadWrite

        /// <summary>
        /// Creates an instance of the ReadWriteAttributeAssignment using the provided XmlReader.
        /// </summary>
        /// <param name="reader">The XmlReader positioned at the AttributeAssignament node.</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public AttributeAssignmentElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Policy, schemaVersion)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (reader.LocalName == Consts.Schema1.ObligationElement.AttributeAssignment &&
                ValidateSchema(reader, schemaVersion))
            {
                if (reader.HasAttributes)
                {
                    // Load all the attributes
                    while (reader.MoveToNextAttribute())
                    {
                        if (reader.LocalName == Consts.Schema1.AttributeValueElement.DataType)
                        {
                            _dataType = reader.GetAttribute(Consts.Schema1.AttributeValueElement.DataType);
                        }
                        else if (reader.LocalName == Consts.Schema1.AttributeAssignmentElement.AttributeId)
                        {
                            _attributeId = reader.GetAttribute(Consts.Schema1.AttributeAssignmentElement.AttributeId);
                        }
                    }
                    reader.MoveToElement();
                }

                // Load the node contents
                _contents = reader.ReadInnerXml();
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:37,代码来源:AttributeAssignmentElementReadWrite.cs

示例8: HeightfieldTerrainGenerator

        public HeightfieldTerrainGenerator(XmlReader r)
        {
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);
                switch (r.Name)
                {
                    case "Type":
                        string type = r.Value;
                        Debug.Assert(type == "HeightfieldMosaic");
                        break;
                    case "MosaicName":
                        heightfieldName = r.Value;
                        break;
                    case "PreloadRadius":
                        preloadRadius = int.Parse(r.Value);
                        break;
                    case "OutsideHeight":
                        outsideHeight = float.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement();
            if (!r.IsEmptyElement)
            {
                do
                {
                    r.Read();
                } while (r.NodeType != XmlNodeType.EndElement);
            }

            Mosaic = new HeightfieldMosaic(heightfieldName, preloadRadius, outsideHeight);
            Mosaic.MosaicModificationStateChanged += Mosaic_OnMosaicModificationStateChanged;
            Mosaic.MosaicChanged += Mosaic_OnMosaicChanged;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:35,代码来源:HeightfieldTerrainGenerator.cs

示例9: ReadNodes

 public static XmlNode[] ReadNodes(XmlReader xmlReader)
 {
     if (xmlReader == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
     XmlDocument doc = new XmlDocument();
     List<XmlNode> nodeList = new List<XmlNode>();
     if (xmlReader.MoveToFirstAttribute())
     {
         do
         {
             if (IsValidAttribute(xmlReader))
             {
                 XmlNode node = doc.ReadNode(xmlReader);
                 if (node == null)
                     throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
                 nodeList.Add(node);
             }
         } while (xmlReader.MoveToNextAttribute());
     }
     xmlReader.MoveToElement();
     if (!xmlReader.IsEmptyElement)
     {
         int startDepth = xmlReader.Depth;
         xmlReader.Read();
         while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
         {
             XmlNode node = doc.ReadNode(xmlReader);
             if (node == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
             nodeList.Add(node);
         }
     }
     return nodeList.ToArray();
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:34,代码来源:XmlSerializableServices.cs

示例10: PolicySetIdReferenceElementReadWrite

 /// <summary>
 /// Creates a policy set id reference using the XmlReader instance provided.
 /// </summary>
 /// <param name="reader">The XmlReader instance positioned at the "PolicySetIdReference" 
 /// node</param>
 /// <param name="schemaVersion">The version of the schema that will be used to validate.</param>
 public PolicySetIdReferenceElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
     : base(XacmlSchema.Policy, schemaVersion)
 {
     if (reader == null) throw new ArgumentNullException("reader");
     if (reader.LocalName == Consts.Schema1.PolicySetIdReferenceElement.PolicySetIdReference &&
         ValidateSchema(reader, schemaVersion))
     {
         if (reader.HasAttributes)
         {
             // Load all the attributes
             while (reader.MoveToNextAttribute())
             {
                 if (reader.LocalName == Consts.Schema2.PolicyReferenceElement.Version)
                 {
                     _version = reader.GetAttribute(Consts.Schema2.PolicyReferenceElement.Version);
                 }
                 else if (reader.LocalName == Consts.Schema2.PolicyReferenceElement.EarliestVersion)
                 {
                     _earliestVersion = reader.GetAttribute(Consts.Schema2.PolicyReferenceElement.EarliestVersion);
                 }
                 else if (reader.LocalName == Consts.Schema2.PolicyReferenceElement.LatestVersion)
                 {
                     _latestVersion = reader.GetAttribute(Consts.Schema2.PolicyReferenceElement.LatestVersion);
                 }
             }
             reader.MoveToElement();
         }
         _policySetIdReference = reader.ReadElementString();
     }
     else
     {
         throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
     }
 }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:40,代码来源:PolicySetIdReferenceElementReadWrite.cs

示例11: ReadXml

        public override void ReadXml(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
                if (!TryReadXmlAttribute(reader))
                    MapXmlReader.HandleUnexpectedAttribute(reader.LocalName);

            reader.MoveToElement();
            if (!reader.IsEmptyElement)
            {
                var isElsePresent = false;
                reader.Read();
                while (reader.MoveToContent() != XmlNodeType.EndElement)
                    if (reader.IsStartElement(When.ElementName) && !isElsePresent)
                    {
                        var when = new When();
                        Nodes.Add(when);
                        when.ReadXml(reader);
                    }
                    else if (reader.IsStartElement(Else.ElementName))
                    {
                        var elseNode = new Else();
                        Nodes.Add(elseNode);
                        elseNode.ReadXml(reader);
                        isElsePresent = true;
                    }
                    else MapXmlReader.HandleUnexpectedElement(reader.LocalName);
            }
            reader.Read();
        }
开发者ID:netgrim,项目名称:MapKit,代码行数:29,代码来源:Case.cs

示例12: ReadXml

        public void ReadXml(XmlReader reader)
        {
            base.ReadXmlAttributes(reader);

            reader.MoveToElement();
            bool empty = reader.IsEmptyElement;
            reader.ReadStartElement(Xml.TestSuite);

            if (!empty)
            {
                reader.ConsumeUntilFirst(XmlReaderHelper.ElementFilter);

                while (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == Xml.TestSuite)
                    {
                        new TestSuite(null, this).ReadXml(reader);
                    }
                    else if (reader.Name == TestCase.Xml.TestCase)
                    {
                        new TestCase(null, this).ReadXml(reader);
                    }

                    reader.ConsumeUntilFirst(XmlReaderHelper.ElementFilter);
                }

                reader.ReadEndElement();
            }
        }
开发者ID:ETAS-Eder,项目名称:vs-boost-unit-test-adapter,代码行数:29,代码来源:TestSuite.cs

示例13: GetFeed

		public static IFeed GetFeed(Uri url, XmlReader reader) {
			reader.MoveToContent();
			string language = string.Empty;
			FeedType feedType;
			string namespaceUri = reader.NamespaceURI;
			if(reader.LocalName.Equals("RDF") &&
				reader.NamespaceURI.Equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) {
				feedType = FeedType.Rdf;
				reader.Read();
				reader.MoveToContent();
			} else if(reader.LocalName.Equals("rss")) {
				feedType = FeedType.Rss;

				do {
					reader.Read();
					reader.MoveToContent();
				} while(!reader.LocalName.Equals("channel") && !reader.LocalName.Equals("rss"));
			} else if(reader.NamespaceURI.Equals("http://purl.org/atom/ns#") && reader.LocalName.Equals("feed")) {
				if(reader.MoveToAttribute("version") && reader.Value.Equals("0.3")) {
					feedType = FeedType.Atom;
					language = reader.XmlLang;
					reader.MoveToElement();
				} else {
					throw new ApplicationException(string.Format("Unsupported Atom Version {0}", reader.Value));
				}
			} else if(reader.NamespaceURI.Equals("http://www.w3.org/2005/Atom") && reader.LocalName.Equals("feed")) {
				feedType = FeedType.Atom;
				language = reader.XmlLang;
			} else {
				throw new ApplicationException("Unknown Xml Dialect");
			}
			return PopulateFeed(url, reader, namespaceUri, feedType, language);
		}
开发者ID:aelveborn,项目名称:njupiter,代码行数:33,代码来源:FeedReader.cs

示例14: ProcessAttributes

        private void ProcessAttributes(XmlReader xmlReader, IReqIfParserCallbackReceiver callbackReceiver)
        {
            while (xmlReader.MoveToNextAttribute())
            {
                callbackReceiver.ProcessAttribute(xmlReader.Name, xmlReader.Value);
            }

            xmlReader.MoveToElement();
        }
开发者ID:johnulist,项目名称:EnterpriseArchitect_ReqIF_AddIn,代码行数:9,代码来源:ReqIfParser.cs

示例15: ReadAttributes

 private static void ReadAttributes(ZXmlNode Node, XmlReader rd)
 {
     for (int i = 0; i < rd.AttributeCount; i++)
     {
         rd.MoveToAttribute(i);
         Node.Attributes.Add(rd.Name, rd.Value);
     }
     rd.MoveToElement();
 }
开发者ID:ZeroByte1987,项目名称:ConsoleGames,代码行数:9,代码来源:XML_Parser.cs


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