本文整理汇总了C#中XmlReader.ReadToNextSibling方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadToNextSibling方法的具体用法?C# XmlReader.ReadToNextSibling怎么用?C# XmlReader.ReadToNextSibling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadToNextSibling方法的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: LoadEnemies
private void LoadEnemies(XmlReader reader) {
reader.ReadStartElement("Enemies");
GameObject enemy = null;
bool enemyToParse = reader.ReadToFollowing ("Enemy");
Debug.Log ("Started parsing enemies..." + enemyToParse);
do {
if(!enemyToParse)
break;
Debug.Log ("Found an enemy");
switch (reader.GetAttribute ("Type")) {
case "Bat":
enemy = Instantiate (prefabDictionary ["Bat"]);
break;
case "Blob":
enemy = Instantiate (prefabDictionary ["Blob"]);
break;
}
enemy.GetComponent<Enemy> ().Load (reader);
} while(reader.ReadToNextSibling("Enemy"));
}
示例4: LoadStatus
/// <summary>
/// Loads the status.
/// </summary>
/// <param name="reader">Reader.</param>
protected override void LoadStatus (XmlReader reader)
{
base.LoadStatus (reader);
reader.ReadToNextSibling ("Mana");
mana.value = reader.ReadElementContentAsFloat ();
Debug.Log("Found Exp field: " + reader.ReadToNextSibling ("Exp"));
Debug.Log("Found level field: " + reader.ReadToNextSibling ("Level"));
GetComponent<Inventory> ().LoadInventory (reader);
reader.ReadEndElement ();
}
示例5: 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 ();
}