本文整理汇总了C#中System.Xml.XmlTextReader.ReadElementString方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextReader.ReadElementString方法的具体用法?C# System.Xml.XmlTextReader.ReadElementString怎么用?C# System.Xml.XmlTextReader.ReadElementString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了System.Xml.XmlTextReader.ReadElementString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get_Definephrase
public static string Get_Definephrase(string tag)
{
try
{
string ffile = "/cmm/xhtml/Definephrase.xml";
string fpath = HttpContext.Current.Server.MapPath(ffile);
if (!System.IO.File.Exists(fpath)) return "";
string vlreturn = "";
System.Xml.XmlTextReader rdr = new System.Xml.XmlTextReader(fpath);
while (rdr.Read())
{
switch (rdr.NodeType)
{
case System.Xml.XmlNodeType.Element:
if (rdr.Name == LANG + tag)
{
vlreturn = rdr.ReadElementString();
goto lexit;
}
else if (rdr.Name != "phrase")
rdr.Skip();
break;
default:
break;
}
}
lexit:
rdr.Close();
return vlreturn;
}
catch
{
return "Cannot get phrase";
}
}
示例2: ProcessFiles
/// <summary>
/// This is the worker thread.
/// </summary>
/// <param name="stateInfo">Not used.</param>
void ProcessFiles(object stateInfo)
{
System.Text.StringBuilder stb = null;
while (_filesToProcess.Count > 0)
{
string fullfilename = _filesToProcess.Dequeue();
try
{
string category = null;
string name = null;
DateTime creationTime = DateTime.MinValue;
string description = string.Empty;
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(fullfilename);
xmlReader.MoveToContent();
while (xmlReader.Read())
{
if (xmlReader.NodeType == System.Xml.XmlNodeType.Element && xmlReader.LocalName == "Category")
{
category = xmlReader.ReadElementString();
name = xmlReader.ReadElementString("Name");
creationTime = System.Xml.XmlConvert.ToDateTime(xmlReader.ReadElementString("CreationTime"), System.Xml.XmlDateTimeSerializationMode.Local);
if (xmlReader.LocalName == "Description")
description = xmlReader.ReadElementString("Description");
break;
}
}
xmlReader.Close();
AddFitFunctionEntry(category, name, creationTime, description, fullfilename);
}
catch (Exception ex)
{
if (stb == null)
stb = new StringBuilder();
stb.AppendLine(ex.ToString());
}
}
if (stb != null)
{
Current.Console.WriteLine("Exception(s) thrown in " + this.GetType().ToString() + " during parsing of fit functions, details will follow:");
Current.Console.WriteLine(stb.ToString());
}
_threadIsWorking = false;
}