本文整理汇总了C#中XmlReader.IsStartElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.IsStartElement方法的具体用法?C# XmlReader.IsStartElement怎么用?C# XmlReader.IsStartElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.IsStartElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _NextToken
private bool _NextToken(XmlReader reader)
{
while (!reader.EOF && reader.Read() && !reader.IsStartElement())
;
return !reader.EOF;
}
示例2: ReadObject
private object ReadObject(string classname, List<object> list, XmlReader reader)
{
object res = null;
int count = 0;
string attribute = null;
int fieldcount;
if (classname == null)
{
reader.Read();
if (reader.IsStartElement())
classname = XmlConvert.DecodeName(reader.Name);
count = Convert.ToInt32(reader["count"]);
}
if (classname == null)
return null;
fieldcount = Convert.ToInt32(reader["fieldcount"]);
attribute = reader["reference"];
reader.Read();
if (reader.IsStartElement() || reader.Value != null)
{
Type objtype = Type.GetType(classname);
if (attribute != null)
{
// string attribute = reader["reference"];
if (attribute != null)
{
res = list[Convert.ToInt32(attribute)];
}
}
else if (objtype.IsPrimitive)
{
res = (object)objtype.InvokeMember("Parse",
BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public,
null, null, new object[] { XmlConvert.DecodeName(reader.Value.Trim()) });
list.Add(res);
}
else if (objtype.Equals(typeof(string)))
{
res = XmlConvert.DecodeName(reader.Value.Trim());
}
else
{
if (objtype.IsArray)
{
//count = Convert.ToInt32(reader["count"]);
int index = 0;
res = Activator.CreateInstance(objtype, count);
list.Add(res);
while (index < count)
{
//reader.Read();
while(!reader.IsStartElement())
reader.Read();
string s = reader.Name;
((System.Array)res).SetValue(ReadObject(s, list, reader), index++);
}
}
else
{
res = Activator.CreateInstance(objtype);
list.Add(res);
int index = 0;
//count = Convert.ToInt32(reader["count"]);
while (index < fieldcount)
{
while (!reader.IsStartElement())
reader.Read();
index++;
string fieldname = reader.Name;
object fieldobject = ReadObject(null, list, reader);
FieldInfo fiendinf = objtype.GetField(fieldname, BindingFlags.GetField | BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
if (fiendinf != null)
fiendinf.SetValue(res, fieldobject);
}
}
}
}
return res;
}
示例3: _GetToken
private bool _GetToken(XmlReader reader, out string strToken)
{
bool fResult = reader.IsStartElement();
strToken = fResult ? reader.LocalName : null;
return fResult;
}
示例4: ExtractClientConfig
/* Method to extract the client specific parts of the config file */
private bool ExtractClientConfig(XmlReader reader)
{
try {
while (reader.Read()) {
if (reader.IsStartElement()) {
if (reader.Name == "client") {
client_config.Add(new ClientConfig());
while (reader.MoveToNextAttribute()) {
if (reader.Name == "name")
client_config.Last().name.Add("short_name", reader.Value);
else if (reader.Name == "lname")
client_config.Last().name.Add("full_name", reader.Value);
else
Console.WriteLine("Unknown report configuration attribute: " + reader.Name);
}
}
else if (reader.Name == "project")
client_config.Last().projects.Add(reader.ReadString());
else if (reader.Name == "priority")
client_config.Last().priority.Add(reader.ReadString());
else if (reader.Name == "email")
client_config.Last().email.Add(reader.ReadString());
}
}
return true;
}
catch (Exception ex) {
Console.WriteLine("Exception when extracting client data from config XML: " + ex.Message);
return false;
}
}