本文整理汇总了C#中XmlTextReader.ReadElementString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader.ReadElementString方法的具体用法?C# XmlTextReader.ReadElementString怎么用?C# XmlTextReader.ReadElementString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadElementString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXML
private void ReadXML()
{
string xmlFile = Server.MapPath("DvdList.xml");
// Create the reader.
XmlTextReader reader = new XmlTextReader(xmlFile);
StringBuilder str = new StringBuilder();
reader.ReadStartElement("DvdList");
// Read all the <DVD> elements.
while (reader.Read())
{
if ((reader.Name == "DVD") && (reader.NodeType == XmlNodeType.Element))
{
reader.ReadStartElement("DVD");
str.Append("<ul><b>");
str.Append(reader.ReadElementString("Title"));
str.Append("</b><li>");
str.Append(reader.ReadElementString("Director"));
str.Append("</li><li>");
str.Append(String.Format("{0:C}",
Decimal.Parse(reader.ReadElementString("Price"))));
str.Append("</li></ul>");
}
}
// Close the reader and show the text.
reader.Close();
XmlText.Text = str.ToString();
}
示例2: Button2_Click
//
private void Button2_Click(System.Object sender, System.EventArgs e)
{
verify.Visible = false;
Button1.Visible = false;
OpenFileDialog1.ShowDialog();
if (string.IsNullOrEmpty(OpenFileDialog1.FileName)) {
return;
} else {
spinny.Visible = true;
Button2.Visible = false;
Delay(1.5);
try {
//Parsing time baby!!!
//Load up xml...
XmlTextReader m_xmlr = null;
m_xmlr = new XmlTextReader(OpenFileDialog1.FileName);
m_xmlr.WhitespaceHandling = WhitespaceHandling.None;
m_xmlr.Read();
m_xmlr.Read();
while (!m_xmlr.EOF) {
m_xmlr.Read();
if (!m_xmlr.IsStartElement()) {
break; // TODO: might not be correct. Was : Exit While
}
dynamic iFaithAttribute = m_xmlr.GetAttribute("iFaith");
m_xmlr.Read();
xml_revision = m_xmlr.ReadElementString("revision");
xml_ios = m_xmlr.ReadElementString("ios");
xml_model = m_xmlr.ReadElementString("model");
xml_board = m_xmlr.ReadElementString("board");
xml_ecid = m_xmlr.ReadElementString("ecid");
blob_logo = m_xmlr.ReadElementString("logo");
blob_chg0 = m_xmlr.ReadElementString("chg0");
blob_chg1 = m_xmlr.ReadElementString("chg1");
blob_batf = m_xmlr.ReadElementString("batf");
blob_bat0 = m_xmlr.ReadElementString("bat0");
blob_bat1 = m_xmlr.ReadElementString("bat1");
blob_dtre = m_xmlr.ReadElementString("dtre");
blob_glyc = m_xmlr.ReadElementString("glyc");
blob_glyp = m_xmlr.ReadElementString("glyp");
blob_ibot = m_xmlr.ReadElementString("ibot");
blob_illb = m_xmlr.ReadElementString("illb");
if (xml_ios.Substring(0, 1) == "3") {
blob_nsrv = m_xmlr.ReadElementString("nsrv");
}
blob_recm = m_xmlr.ReadElementString("recm");
blob_krnl = m_xmlr.ReadElementString("krnl");
xml_md5 = m_xmlr.ReadElementString("md5");
xml_ipsw_md5 = m_xmlr.ReadElementString("ipsw_md5");
}
m_xmlr.Close();
} catch (Exception Ex) {
Interaction.MsgBox("Error while processing specified file!", MsgBoxStyle.Critical);
spinny.Visible = false;
Button2.Visible = true;
return;
}
}
//Were going to Check to see if this was made with a newer iFaith revision...
if (xml_revision > MDIMain.VersionNumber) {
Interaction.MsgBox("This iFaith SHSH Cache file was made with iFaith v" + xml_revision + Strings.Chr(13) + Strings.Chr(13) + "Please download the latest iFaith revision at http://ih8sn0w.com", MsgBoxStyle.Critical);
spinny.Visible = false;
Button2.Visible = true;
return;
}
//Hashing time! :)
if (MD5CalcString(blob_logo + xml_ecid + xml_revision) == xml_md5) {
if (xml_board == "n72ap") {
Interaction.MsgBox("iPod Touch 2G IPSW Creation is still being worked on.", MsgBoxStyle.Exclamation);
spinny.Visible = false;
Button2.Visible = true;
return;
}
//Load IPSW Pwner...
verify.Visible = false;
//Hide Logo + Welcome txt...
PictureBox1.Visible = false;
spinny.Visible = false;
Label1.Visible = false;
//
ORlabel.Visible = true;
dl4mebtn.Visible = true;
browse4ios.Visible = true;
browse4ios.Text = "Browse for the " + xml_ios;
browse4ios.ForeColor = Color.Cyan;
browse4ios.Left = (Width / 2) - (browse4ios.Width / 2);
if (xml_board == "n92ap") {
Label2.Text = "IPSW for the iPhone 4 (CDMA)";
} else {
Label2.Text = "IPSW for the " + xml_model;
}
Label2.ForeColor = Color.Cyan;
Label2.Left = (Width / 2) - (Label2.Width / 2);
Button3.Text = "Browse for the iOS " + xml_ios + " IPSW";
Button3.Left = (Width / 2) - (Button3.Width / 2);
Button2.Visible = false;
Button3.Visible = true;
//.........这里部分代码省略.........
示例3: Load
//loads all the objects in the cell
public void Load()
{
if(File.Exists(fileName) && status != CellStatus.active)
{
if(positions.Count <= 0 && perlin.Count <= 0)
{
positions = new List<Vector2>();
perlin = new List<float>();
XmlTextReader reader = new XmlTextReader(fileName);
while(reader.Read())
{
if(reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
{
switch(reader.Name)
{
case "AsteroidPosition" :
positions.Add(new Vector2(float.Parse(reader.GetAttribute(0)), float.Parse(reader.GetAttribute(1))));
break;
case "PerlinValue":
perlin.Add( float.Parse(reader.ReadElementString()));
break;
}
}
}
reader.Close ();
}
children.Clear ();
Vector2 indexes = ObjectPool.Pool.Redirect(positions, perlin, this);
if(indexes.x >= 0 && indexes.x < positions.Count)
{
for(int i = (int)indexes.x, j = (int)indexes.y; i < positions.Count && j < perlin.Count; i++,j++)
{
GameObject asteroidOBJ = GameObject.Instantiate(Resources.Load("Asteroid/Asteroid")) as GameObject;
asteroidOBJ.transform.parent = parent.transform;
Asteroid temp = asteroidOBJ.AddComponent<Asteroid>();
temp.assignedPosition = positions[i];
temp.perlinValue = perlin[j];
temp.parentCell = this;
temp.Change();
children.Add(asteroidOBJ);
if(ObjectPool.Pool.CanPoolMore())
{
ObjectPool.Pool.Register(asteroidOBJ);
}
}
}
}
}
示例4: LoadData
public void LoadData()
{
int setIndex = 0;
if (!File.Exists(savePath))
{
Debug.Log("PlayerInfo.xml not found @ " + savePath);
return;
}
else
{
Debug.Log("Loading PlayerInfo.xml @ \n" + savePath);
}
XmlReader reader = new XmlTextReader (savePath);
items.Clear();
while (reader.Read())
{
if (reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "bDisplayTutorial":
{
bDisplayTutorial = bool.Parse(reader.ReadElementString());
break;
}
case "CurrentScene":
{
currentScene = reader.ReadElementString();
break;
}
case "PlayerPos":
{
float x = float.Parse(reader.GetAttribute(0));
float y = float.Parse(reader.GetAttribute(1));
float z = float.Parse(reader.GetAttribute(2));
playerPos = new Vector3 (x, y, z);
break;
}
case "CameraPos":
{
float x = float.Parse(reader.GetAttribute(0));
float y = float.Parse(reader.GetAttribute(1));
float z = float.Parse(reader.GetAttribute(2));
cameraPos = new Vector3 (x, y, z);
break;
}
case "Item":
{
items.Add(new Item());
setIndex = items.Count - 1;
break;
}
case "ItemName":
{
items[setIndex].itemName = reader.ReadElementString();
break;
}
case "ItemID":
{
items[setIndex].itemID = int.Parse(reader.ReadElementString());
break;
}
case "ItemDescription":
{
items[setIndex].itemDescription = reader.ReadElementString();
break;
}
case "SpriteName":
{
items[setIndex].spriteName = reader.ReadElementString();
break;
}
case "HasItem":
{
items[setIndex].hasItem = bool.Parse(reader.ReadElementString());
break;
}
default:
{
break;
}
}
}
}
}
示例5: LoadData
//Used for loading saved player information
public void LoadData()
{
XMLFileManager.DecryptFile(savePath);
XmlReader reader = new XmlTextReader(savePath);
while(reader.Read())
{
if(reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
{
switch(reader.Name)
{
case "deviceID":
deviceID = reader.ReadElementString();
break;
case "ship":
ship = reader.ReadElementString();
break;
case "playerPosition":
string[] positions = reader.ReadElementString().Split(',');
transform.position = new Vector2(float.Parse(positions[0]), float.Parse(positions[1]) );
break;
case "maxHealth":
maxHealth = int.Parse(reader.ReadElementString());
break;
case "currentHealth":
currentHealth = int.Parse(reader.ReadElementString());
break;
case "maxShields":
maxShields = int.Parse(reader.ReadElementString());
break;
case "currentShields":
currentShields = int.Parse(reader.ReadElementString());
break;
case "shieldRechargeDelay":
shieldRechargeDelay = int.Parse(reader.ReadElementString());
break;
case "shieldRechargeRate":
shieldRechargeRate = int.Parse(reader.ReadElementString());
break;
case "maxFuel":
maxFuel = float.Parse(reader.ReadElementString());
break;
case "currentFuel":
currentFuel = float.Parse(reader.ReadElementString());
break;
case "fuelConsumptionRate":
fuelConsumptionRate = float.Parse(reader.ReadElementString());
break;
case "acceleration":
acceleration = float.Parse(reader.ReadElementString());
break;
case "speed":
speed = float.Parse(reader.ReadElementString());
break;
case "maxSpeed":
maxSpeed = float.Parse(reader.ReadElementString());
break;
case "thrusterDelay":
thrusterDelay = float.Parse(reader.ReadElementString());
break;
case "rotationSpeed":
rotationSpeed = float.Parse(reader.ReadElementString());
break;
case "currentWeapon":
WeaponManager.Instance.ChangeStartUpAmmoType( (WeaponManager.ammoType)Enum.Parse(typeof(WeaponManager.ammoType),reader.ReadElementString()));
break;
case "currentMaxAmmo":
WeaponManager.Instance.MaxAmmo = float.Parse(reader.ReadElementString());
break;
case "currentAmmo":
WeaponManager.Instance.CurrentAmmo = float.Parse(reader.ReadElementString());
break;
case "beam_MAX":
WeaponManager.Instance.totalMaxAmmo[WeaponManager.ammoType.beam] = float.Parse(reader.ReadElementString());
break;
case "chaser_MAX":
WeaponManager.Instance.totalMaxAmmo[WeaponManager.ammoType.chaser] = float.Parse(reader.ReadElementString());
break;
case "standard_MAX":
WeaponManager.Instance.totalMaxAmmo[WeaponManager.ammoType.standard] = float.Parse(reader.ReadElementString());
break;
case "beam_CURRENT":
WeaponManager.Instance.totalCurrentAmmo[WeaponManager.ammoType.beam] = float.Parse(reader.ReadElementString());
break;
case "chaser_CURRENT":
WeaponManager.Instance.totalCurrentAmmo[WeaponManager.ammoType.chaser] = float.Parse(reader.ReadElementString());
break;
case "standard_CURRENT":
WeaponManager.Instance.totalCurrentAmmo[WeaponManager.ammoType.standard] = float.Parse(reader.ReadElementString());
break;
default:
Debug.Log(reader.Name);
break;
}
}
}
reader.Close();
//.........这里部分代码省略.........