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


C# XmlReader.ReadToDescendant方法代码示例

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


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

示例1: CreateGeneratorFromXml

    public static QuestionGenerator CreateGeneratorFromXml(XmlReader reader)
    {
        bool used = reader.GetAttribute("Used").Equals("y");
        if(!used) return null;
        QuestionGenerator generator = new QuestionGenerator();
        generator.m_tags = reader.GetAttribute("Tags").Split(';');
        generator.m_type = (GeneratorType)System.Enum.Parse(typeof(GeneratorType), reader.GetAttribute("Type"));
        generator.m_weight = System.Convert.ToSingle(reader.GetAttribute("Weight"));
        generator.m_questionText = reader.GetAttribute("QuestionText");
        generator.m_adjacentWithin = System.Convert.ToInt32(reader.GetAttribute("AdjacentWithin"));
        generator.m_infoPrefix = reader.GetAttribute("InfoPrefix");
        generator.m_infoSuffix = reader.GetAttribute("InfoSuffix");
        bool preventDuplicates = generator.m_type == GeneratorType.SortedMultiset;

        reader.ReadToDescendant("Answer");
        do{
            generator.AddAnswer(reader.GetAttribute("Text"), reader.GetAttribute("Value"), preventDuplicates);
        }while(reader.ReadToNextSibling("Answer"));
        return generator;
    }
开发者ID:EmileKroeger,项目名称:Credence,代码行数:20,代码来源:QuestionGenerator.cs

示例2: ReadData

    /// <summary>
    /// Reads a specific data tag from the xml document.
    /// </summary>
    /// <param name='reader'>
    /// Reader.
    /// </param>
    private void ReadData(XmlReader reader)
    {
        //If these values are not being set,
        //something is wrong.
        string key = "ERROR";

        string value = "ERROR";

        if (reader.HasAttributes)
        {
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "name")
                {
                    key = reader.Value;
                }
            }
        }

        //Move back to the element
        reader.MoveToElement();

        //Read the child nodes
        if (reader.ReadToDescendant("value"))
        {
            do
            {
                value = reader.ReadString();
            }
            while (reader.ReadToNextSibling("value"));
        }

        //Add the raw values to the dictionary
        textDataBase.Add(key, value);

        //Add the localized parsed values to the localizedObjectDataBase
        LocalizedObject newLocalizedObject = new LocalizedObject();
        newLocalizedObject.ObjectType = LocalizedObject.GetLocalizedObjectType(key);
        newLocalizedObject.TextValue = value;
        localizedObjectDataBase.Add(LocalizedObject.GetCleanKey(key,newLocalizedObject.ObjectType), newLocalizedObject);
    }
开发者ID:Gris87,项目名称:PingPong3D,代码行数:47,代码来源:LanguageManager.cs

示例3: Reset

 public void Reset()
 {
     reader = new XmlTextReader(filePath);
     reader.ReadToDescendant("Event");
 }
开发者ID:bluquar,项目名称:Unity-Logger,代码行数:5,代码来源:XMLLogReader.cs

示例4: LoadPosition

	protected void LoadPosition(XmlReader reader) {
		reader.ReadToFollowing ("Position");
		reader.ReadToDescendant ("x");
		Vector3 loadedPosition = new Vector3 ();
		loadedPosition.x = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("y");
		loadedPosition.y = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("z");
		loadedPosition.z = reader.ReadElementContentAsFloat ();
		transform.position = loadedPosition;
		reader.ReadEndElement ();
	}
开发者ID:TobiasMorell,项目名称:Game2Grow-Wizard,代码行数:12,代码来源:Entity.cs

示例5: LoadStatus

	protected virtual void LoadStatus (XmlReader reader) {
		reader.ReadToFollowing ("Status");
		reader.ReadToDescendant ("HP");
		HP = reader.ReadElementContentAsInt ();
	}
开发者ID:TobiasMorell,项目名称:Game2Grow-Wizard,代码行数:5,代码来源:Entity.cs


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