本文整理汇总了C#中XmlTextReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader.ReadString方法的具体用法?C# XmlTextReader.ReadString怎么用?C# XmlTextReader.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) //sürekli japon yeni ni ekliyodu butonda bu yüzden bunu ekledik sadece ilk postback olduğunda yapar sonraki postbackları yapmaz
{
ListItem aa;
//ddlKurlar.Items.Add(new ListItem("japon yeni", "2,2")); 7/merkez bankasından xml alıcaz
XmlTextReader re = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
string txt = "";
string value = "";
while (re.Read()) {
if(re.NodeType==XmlNodeType.Element)
if (re.Name == "Isim") {
txt = re.ReadString();
}
if (re.Name == "CrossRateUSD")
{
value = re.ReadString();
if (value == "")
continue; //boş değerleri böylece götürdük ddl deki
aa = new ListItem();
aa.Text = txt;
aa.Value = value.Replace(".", ",");
ddlKurlar.Items.Add(aa);
}
}
}
}
示例2: ReadXml
private static string ReadXml(string filename, int ID)
{
string strLastVersion = "";
XmlTextReader reader = new XmlTextReader(filename);
while (reader.Read())
{
if (reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
if (reader.Name == "id")
{
if (reader.Value == ID.ToString())
{
strLastVersion = reader.ReadString();
reader.Close();
return strLastVersion;
}
}
}
}
}
return strLastVersion;
}
示例3: ReadXML
void ReadXML()
{
int typesCount = (int)MessageType.Count;
messages = new List<string>[typesCount];
for(int i = 0; i < typesCount; i++) {
messages[i] = new List<string>();
}
XmlTextReader reader = new XmlTextReader (file.text, XmlNodeType.Element, null);
while(reader.Read()) {
string typeName = reader.Name;
if(string.IsNullOrEmpty(typeName)) {
continue;
}
string message = reader.ReadString();
int mTypeIndex = (int)((MessageType)System.Enum.Parse(typeof(MessageType), typeName));
if(mTypeIndex >= 0 && mTypeIndex < typesCount) {
messages[mTypeIndex].Add(message);
// Debug.Log("Adding message: " + message + " for type " + typeName);
} else {
Debug.LogError("Unknown type " + typeName);
}
}
}
示例4: LoadXML
void LoadXML()
{
file = Resources.Load("sprites/cfg/" + effect.name) as TextAsset;
XmlTextReader reader = new XmlTextReader(new StringReader(file.text));
frame = 1;
while(reader.Read())
{
switch (reader.Name)
{
case "x": x = float.Parse (reader.ReadString()); break;
case "y": y = float.Parse (reader.ReadString()); break;
case "offsetX": offsetX = float.Parse (reader.ReadString()); break;
case "offsetY": offsetY = float.Parse (reader.ReadString()); break;
case "no" : _frame = int.Parse(reader.ReadString()); if ( _frame == frame) { pos.Add(new coords(x, y, offsetX, offsetY)); frame++;} break;
}
}
}
示例5: ReadLocale
private void ReadLocale(XmlTextReader reader)
{
TransfluentUtility util = TransfluentUtility.GetInstance();
while (reader.Read())
{
if (reader.IsStartElement())
{
//util.AddMessage("Start locale entry element: " + reader.Name);
if (reader.Name.Equals("id"))
{
string id = reader.ReadString();
if (!int.TryParse(id, out m_languageId))
util.AddError("Couldn't parse language id from '" + id + "'");
}
if (reader.Name.Equals("code"))
m_languageCode = reader.ReadString();
if (reader.Name.Equals("name"))
m_languageName = reader.ReadString();
if (reader.Name.Equals("texts"))
ReadTexts(reader);
}
else if (reader.Name.Equals("locale"))
{
// Done reading locale
//util.AddMessage("End of locale");
break;
}
else
util.AddWarning("Unexpected element closed: " + reader.Name);
}
if (m_languageId == -1)
util.AddError("Couldn't parse language id");
if (m_languageCode == null)
util.AddError("Couldn't parse language code");
if (m_languageName == null)
util.AddError("Couldn't parse language name");
if (m_texts.Count == 0)
util.AddWarning("No texts parsed or found");
}
示例6: GetMetaData
public IList<string> GetMetaData(string xml)
{
IList<string> datasource = new List<string>();
string VariableName = "";
string SiteName = "";
string UnitName = "";
string latitude = "";
string longitude = "";
StringReader reader1 = new StringReader(xml);
XmlTextReader reader = new XmlTextReader(reader1);
using (reader)
{
while (reader.Read())
{
string readerName = reader.Name.ToLower();
if (readerName == "variablename")
{
VariableName = reader.ReadString();
datasource.Add(VariableName);
}
if (readerName == "sitename")
{
SiteName = reader.ReadString();
datasource.Add(SiteName);
}
if (readerName == "latitude")
{
latitude = reader.ReadString();
datasource.Add(latitude);
}
if (readerName == "longitude")
{
longitude = reader.ReadString();
datasource.Add(longitude);
}
if (readerName == "unitname")
{
UnitName = reader.ReadString();
datasource.Add(UnitName);
}
else if (readerName == "units")
{
UnitName = reader.ReadString();
datasource.Add(UnitName);
}
}
return datasource;
}
}
示例7: rss_update
private void rss_update(object sender, EventArgs e)
{
int i;
string title;
int toggler = 1;
try
{
led_line = "";
reader = new XmlTextReader(url);
using(reader)
{
reader.Read();
reader.MoveToContent();
i = 0;
while(!reader.EOF)
{
while(!reader.EOF && reader.Name != "item")
reader.Read();
while(!reader.EOF && reader.Name != "title")
reader.Read();
if(!reader.EOF)
{
title = reader.ReadString();
titles[i++] = title;
led_line += title+ " ";
if(toggler == 1)
led_line += "%r";
else
led_line += "%g";
toggler ^= 1;
}
}
num_titles = i;
}
}
catch(Exception)
{
return;
}
}
示例8: SecenkListele
private void SecenkListele( string xmlFileName)
{
List<Secenek> secenekler = new List<Secenek>();
using (XmlTextReader reader = new XmlTextReader(Server.MapPath("~/App_Data/" + xmlFileName + ".xml")))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "secenek")
{
secenekler.Add(new Secenek
{
Name = xmlFileName,
Value = reader.ReadString()
});
}
}
gvwSecenek.DataSource = secenekler;
gvwSecenek.DataBind();
}
}
示例9: ReadXml
private static string ReadXml(string filename, int id)
{
string lastVersion = string.Empty;
XmlTextReader reader = new XmlTextReader(filename);
while (reader.Read())
{
if (reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
if (reader.Name == "id")
{
if (reader.Value == id.ToString())
{
return lastVersion = reader.ReadString();
}
}
}
}
}
return lastVersion;
}
示例10: GetDatabaseVersion
} // End of the CreateXmlRow method
/// <summary>
/// Get the database version from an xml file
/// </summary>
/// <returns>The database version as an int</returns>
public static Int32 GetDatabaseVersion()
{
// Create the int to return
Int32 databaseVersion = 0;
// Set the filename
string filename = HttpContext.Current.Server.MapPath("/DatabaseFiles/DatabaseVersion.xml.gz");
// Check if the file exists
if (File.Exists(filename) == false)
return databaseVersion;
// Create variables
GZipStream gzipStream = null;
XmlTextReader xmlTextReader = null;
try
{
// Create a gzip stream
gzipStream = new GZipStream(new FileStream(filename, FileMode.Open), CompressionMode.Decompress);
// Create a xml text reader
xmlTextReader = new XmlTextReader(gzipStream);
// Read the xml file
while (xmlTextReader.Read())
{
// Get specific information
if (xmlTextReader.Name == "Version")
Int32.TryParse(xmlTextReader.ReadString(), out databaseVersion);
}
}
catch (Exception e)
{
throw e;
}
finally
{
// Close streams
if (xmlTextReader != null)
{
// Close the XmlTextReader
xmlTextReader.Close();
}
if (gzipStream != null)
{
// Close the gzip stream
gzipStream.Close();
}
}
// Return the database version
return databaseVersion;
} // End of the GetDatabaseVersion method
示例11: Main
public static void Main(string[] args) {
if (args.Length != 3) {
Console.WriteLine("Usage:genheaders XML-file header-file resorce-file");
return;
}
ValidateXML(args[0]);
String Message=null;
String SymbolicName=null;
String NumericValue=null;
String tempheaderfile = "temp.h";
String temprcfile = "temp.rc";
StreamWriter HSW=File.CreateText(tempheaderfile);
StreamWriter RSW=File.CreateText(temprcfile);
int FaciltyUrt=0x13;
int SeveritySuccess=0;
int SeverityError=1;
int minSR = MakeHresult(SeveritySuccess,FaciltyUrt,0);
int maxSR = MakeHresult(SeveritySuccess,FaciltyUrt,0xffff);
int minHR = MakeHresult(SeverityError,FaciltyUrt,0);
int maxHR = MakeHresult(SeverityError,FaciltyUrt,0xffff);
PrintHeader(HSW);
PrintResourceHeader(RSW);
XmlTextReader rdr = new XmlTextReader(args[0]);
rdr.WhitespaceHandling = WhitespaceHandling.None;
while (rdr.Read()) {
switch (rdr.NodeType) {
case XmlNodeType.Element:
if (rdr.Name.ToString() == "HRESULT") {
NumericValue=rdr.GetAttribute("NumericValue");
}
if (rdr.Name.ToString() == "Message") {
Message = rdr.ReadString();
}
if (rdr.Name.ToString() == "SymbolicName") {
SymbolicName = rdr.ReadString();
}
break;
case XmlNodeType.EndElement:
if(rdr.Name.ToString() == "HRESULT"){
// For CLR Hresult's we take the last 4 digits as the resource strings.
if ( (NumericValue.StartsWith("0x")) || (NumericValue.StartsWith("0X")) ) {
String HexResult = NumericValue.Substring(2);
int num = int.Parse(HexResult, System.Globalization.NumberStyles.HexNumber);
if ((num>minSR) && (num <= maxSR)) {
num = num & 0xffff;
HSW.WriteLine("#define " + SymbolicName + " SMAKEHR(0x" + num.ToString("x") + ")");
} else if ((num>minHR) && (num <= maxHR)) {
num = num & 0xffff;
HSW.WriteLine("#define " + SymbolicName + " EMAKEHR(0x" + num.ToString("x") + ")");
} else {
HSW.WriteLine("#define " + SymbolicName + " " + NumericValue );
}
} else {
HSW.WriteLine("#define " + SymbolicName + " " + NumericValue );
}
if (Message != null) {
RSW.Write("\tMSG_FOR_URT_HR(" + SymbolicName + ") ");
RSW.WriteLine(Message);
}
SymbolicName = null;
NumericValue = null;
Message = null;
}
break;
}
}
PrintFooter(HSW);
PrintResourceFooter(RSW);
HSW.Close();
RSW.Close();
bool AreFilesEqual = false;
if (File.Exists(args[1])) {
//.........这里部分代码省略.........
示例12: FromXmlString
public override void FromXmlString(string xmlString)
{
StringReader input = new StringReader(xmlString);
XmlTextReader xmlTextReader = new XmlTextReader(input);
this.class14_0 = (this.class14_1 = (this.class14_2 = (this.class14_3 = (this.class14_4 = (this.class14_5 = (this.class14_6 = (this.class14_7 = null)))))));
while (true)
{
XmlNodeType xmlNodeType = xmlTextReader.MoveToContent();
XmlNodeType xmlNodeType2 = xmlNodeType;
switch (xmlNodeType2)
{
case XmlNodeType.None:
return;
case XmlNodeType.Element:
{
string name = xmlTextReader.Name;
if (!this.method_15(xmlTextReader, name, "Modulus", ref this.class14_0) && !this.method_15(xmlTextReader, name, "Exponent", ref this.class14_1) && !this.method_15(xmlTextReader, name, "P", ref this.class14_2) && !this.method_15(xmlTextReader, name, "Q", ref this.class14_3) && !this.method_15(xmlTextReader, name, "DP", ref this.class14_4) && !this.method_15(xmlTextReader, name, "DQ", ref this.class14_5) && !this.method_15(xmlTextReader, name, "InverseQ", ref this.class14_6) && !this.method_15(xmlTextReader, name, "D", ref this.class14_7))
{
xmlTextReader.ReadString();
}
break;
}
default:
if (xmlNodeType2 != XmlNodeType.EndElement)
{
goto Block_9;
}
xmlTextReader.ReadEndElement();
break;
}
}
Block_9:
throw new ArgumentException();
}
示例13: DisplayPathToExamples
protected void DisplayPathToExamples()
{
try
{
XmlTextReader oXMLReader = null;
oXMLReader = new XmlTextReader(Server.MapPath("examples.xml"));
while (oXMLReader.Read())
{
if (oXMLReader.NodeType == XmlNodeType.Element && oXMLReader.Name == "path")
{
lblPath.Text = "<b>Path to folder with Poll examples: </b>" + oXMLReader.ReadString();
}
}
oXMLReader.Close();
}
catch (Exception ex)
{
if (ex != null) { ex = null; }
}
if (Request.QueryString["type"] != null)
{
ExamplesType.Value = Request.QueryString["type"].ToString();
}
}
示例14: xmlparse
// pseudo SAX reader
public static void xmlparse(string fname)
{
XmlReader reader = new XmlTextReader(fname);
string line;
urls = new ArrayList();
int cnt = 0;
// http://msdn.microsoft.com/en-us/library/1z92b1d4.aspx
// http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readsubtree.aspx
while (reader.Read()) {
if (reader.MoveToContent() == XmlNodeType.Element &&
reader.Name == "formvals") {
XmlReader inner = reader.ReadSubtree();
StringDictionary myCol = new StringDictionary();
while (inner.Read()) {
if (inner.MoveToContent() == XmlNodeType.Element &&
inner.Name == "input") {
inner.MoveToFirstAttribute();
// to avoid dependency on the attribute order, key them by the attribute name
// amended with the unique count of the current input element.
myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
inner.MoveToNextAttribute();
myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
cnt++;
}
DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
myCol.CopyTo(myArr, 0);
for (int i = 0; i < myArr.Length; i++) {
try{
string inputNameRegExp = @"name\-(?<input>\d+)";
MatchCollection myMatchCollection =
Regex.Matches(myArr[i].Key.ToString(), inputNameRegExp );
foreach (Match myMatch in myMatchCollection) {
string pos = myMatch.Groups["input"].Value.ToString();
// do not use StringDictionary for final formvals or you have your keyc converted to lower case.
formvals.Add(myCol[String.Format("name-{0}", pos)], myCol[String.Format("value-{0}", pos)]);
}
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
myCol.Clear();
}
foreach ( KeyValuePair<string, string> kvp in formvals )
Console.WriteLine("formvals[ {0} ] = {1}", kvp.Key, kvp.Value);
inner.Close();
}
if (reader.MoveToContent() == XmlNodeType.Element && reader.Name == "url") {
line = reader.ReadString();
urls.Add(line);
Console.WriteLine(line);
}
}
}
示例15: ParseGetValues
public IList<DataValues.DataValues> ParseGetValues(string xml)
{
IList<DataValues.DataValues> results = new List<DataValues.DataValues>();
DataValues.DataValues val;
StringReader reader1 = new StringReader(xml);
XmlTextReader reader = new XmlTextReader(reader1);
using (reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
string readerName = reader.Name.ToLower();
if (readerName == "value")
{
if (reader.HasAttributes)
{
val = new DataValues.DataValues();
//there may be an uppercase or a lowercase dateTime attribute
string localDateTime = reader.GetAttribute("dateTime");
if (string.IsNullOrEmpty(localDateTime))
{
localDateTime = reader.GetAttribute("DateTime");
}
string strVal = reader.ReadString();
if (strVal != "" && localDateTime != "")
{
val.LocalDateTime = Convert.ToDateTime(localDateTime, CultureInfo.InvariantCulture);
val.Value = Convert.ToDouble(strVal, CultureInfo.InvariantCulture);
results.Add(val);
}
}
}
}
}
return results;
}
}