本文整理汇总了C#中XmlReader.ReadStartElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadStartElement方法的具体用法?C# XmlReader.ReadStartElement怎么用?C# XmlReader.ReadStartElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadStartElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXml
public void ReadXml(XmlReader reader)
{
reader.ReadStartElement(); //wrapping element
this.name = reader.ReadElementContentAsString();
this.extension = reader.ReadElementContentAsString();
string tempFileName = Path.GetTempFileName();
this.streamFileName = tempFileName;
using (FileStream fs = File.Create(tempFileName))
{
byte[] buffer = new byte[1000];
int bytesRead;
reader.ReadStartElement();
do
{
bytesRead = reader.ReadContentAsBase64(buffer, 0, buffer.Length);
fs.Write(buffer, 0, bytesRead);
} while (bytesRead > 0);
reader.ReadEndElement();
}
reader.ReadEndElement(); //wrapping element
}
示例2:
void IXmlSerializable.ReadXml(XmlReader r)
{
r.MoveToContent();
r.ReadStartElement("Employee");
r.ReadStartElement("Name");
FirstName = r.ReadElementString("First", ns);
LastName = r.ReadElementString("Last", ns);
r.ReadEndElement();
r.MoveToContent();
ID = Int32.Parse(r.ReadElementString("ID", ns));
r.ReadEndElement();
}
示例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: ReadObject
public static void ReadObject(XmlReader reader, object obj, PropertyConversionHandler handler = null)
{
if (obj == null)
throw new ArgumentNullException("obj");
reader.MoveToContent();
if (obj is IXmlSerializable)
{
((IXmlSerializable)obj).ReadXml(reader);
}
else
{
object oVal = null;
string oName = GetAttributeValue(obj.GetType(), typeof(XmlRootAttribute), "ElementName", true, ref oVal) ? oVal.ToString() : obj.GetType().Name;
if (reader.LocalName != oName)
throw new XmlException("XML element name does not match object.");
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
reader.MoveToContent();
ReadObjectProperties(reader, obj, handler);
reader.ReadEndElement();
}
else
reader.Skip();
}
}