本文整理汇总了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;
}
示例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);
}
示例3: Reset
public void Reset()
{
reader = new XmlTextReader(filePath);
reader.ReadToDescendant("Event");
}
示例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 ();
}
示例5: LoadStatus
protected virtual void LoadStatus (XmlReader reader) {
reader.ReadToFollowing ("Status");
reader.ReadToDescendant ("HP");
HP = reader.ReadElementContentAsInt ();
}