本文整理匯總了C#中System.Xml.XmlTextReader.MoveToNextAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.MoveToNextAttribute方法的具體用法?C# XmlTextReader.MoveToNextAttribute怎麽用?C# XmlTextReader.MoveToNextAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.MoveToNextAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LoadVideoFile
public List<string> LoadVideoFile(string file)
{
List<string> videos = new List<string>();
using (XmlReader reader = new XmlTextReader(file))
{
do
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
reader.MoveToFirstAttribute();
title.Add(reader.Value);
reader.MoveToNextAttribute();
author.Add(reader.Value);
reader.MoveToNextAttribute();
videos.Add(reader.Value);
WriteXNBVideoData(reader.Value);
break;
}
} while (reader.Read());
}
title.RemoveAt(0);
author.RemoveAt(0);
videos.RemoveAt(0);
return videos;
}
示例2: ListPlaces
public static void ListPlaces()
{
string siteDir = HttpContext.Current.Server.MapPath(@"\");
XmlTextReader reader = new XmlTextReader(siteDir + InputFile);
Hall pList = new Hall();
Places p = null;
int category = 0;
int series = 0;
int place = 0;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "category":
reader.MoveToNextAttribute();
category = Int32.Parse(reader.Value);
break;
case "row":
reader.MoveToNextAttribute();
series = Int32.Parse(reader.Value);
break;
case "seat":
reader.Read();
place = Int32.Parse(reader.Value);
p = new Places(series, place, category);
pList.Add(p);
break;
}
}
}
}
示例3: readXml
public void readXml()
{
using (XmlTextReader reader = new XmlTextReader("dump.xml"))
{
reader.ReadToFollowing("range");
while (reader.EOF == false)
{
reader.MoveToFirstAttribute();
rangeNameList.Add(reader.Value);
reader.MoveToNextAttribute();
string temp = (reader.Value);
rangeNameList.Add(temp);
rangeStartList.Add(Int32.Parse(reader.Value, System.Globalization.NumberStyles.HexNumber));
reader.MoveToNextAttribute();
temp = (reader.Value);
rangeNameList.Add(temp);
int temp1 = (Int32.Parse(reader.Value, System.Globalization.NumberStyles.HexNumber));
int temp2 = rangeStartList[rangeStartList.Count-1];
rangeLengthList.Add(temp1-temp2);
reader.ReadToFollowing("range");
}
}
}
示例4: GetJumpUrlToNextPage
public string GetJumpUrlToNextPage(System.Web.HttpServerUtility server,string url, string valueKey)
{
if (!url.ToLower().Contains(".xml"))
{
url += ".xml";
}
XmlTextReader objXMLReader = new XmlTextReader(server.MapPath(url));
string strNodeResult = "";
while (objXMLReader.Read())
{
if (objXMLReader.NodeType.Equals(XmlNodeType.Element))
{
if (objXMLReader.AttributeCount > 0)
{
while (objXMLReader.MoveToNextAttribute())
{
if ("id".Equals(objXMLReader.Name) && valueKey.Equals(objXMLReader.Value))
{
if (objXMLReader.MoveToNextAttribute())
{
strNodeResult = objXMLReader.Value;
}
}
}
}
}
}
return strNodeResult;
}
示例5: Build
/**
* Instantiate the sprites variable using SCMLPath in S2USettings
* */
public void Build ()
{
string pathScml = S2USettings.Settings.ScmlPath;
string folderPath = pathScml.Substring (0, pathScml.LastIndexOf ("/") + 1);
if (!File.Exists (pathScml)) {
Debug.LogErrorFormat ("Unable to open SCML Follower File '{0}'. Reason: File does not exist", pathScml);
return;
}
int id = 0;
int folderId = 0;
XmlTextReader reader = new XmlTextReader (pathScml);
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element: // The node is an element.
if (reader.Name == "folder") {
while (reader.MoveToNextAttribute()) { // Read the attributes.
if (reader.Name == "id") {
folderId = Int32.Parse (reader.Value);
sprites.Add (folderId, new List<Sprite> ());
}
}
}
if (reader.Name == "file") {
while (reader.MoveToNextAttribute()) { // Read the attributes.
if (reader.Name == "id") {
id = Int32.Parse (reader.Value);
}
if (reader.Name == "name") {
sprites [folderId].Insert (id, (Sprite)AssetDatabase.LoadAssetAtPath (folderPath + reader.Value, typeof(Sprite)));
if (sprites [folderId] [id] == null) {
Debug.LogErrorFormat ("Sprite {0} is missing from ressources, this might cause issues", reader.Value);
}
}
}
}
break;
}
}
reader.Close ();
}
示例6: LoadSettings
public void LoadSettings()
{
if (!File.Exists("settings.xml")) return;
var reader = new XmlTextReader("settings.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
while (reader.MoveToNextAttribute()) // Read the attributes.
Console.Write(" " + reader.Name + "='" + reader.Value + "'");
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine(reader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
}
}
示例7: Cargar
public override void Cargar(XmlTextReader reader, ETLConfig configuracion)
{
if ((reader.NodeType != XmlNodeType.Element) ||
(reader.Name != entidad))
{
ErrorEntidad(entidad);
}
string id = null;
string val = null;
// carga los atributos
while (reader.MoveToNextAttribute())
{
switch (reader.Name)
{
case "id" : id = reader.Value; break;
case "val" : val = reader.Value; break;
default : ErrorAtributo(entidad,
reader.Name, reader.Value, reader.LineNumber);
break;
}
}
// carga el id
if (id != null) this.id = id;
// carga el valor
if (val != null) this.valor = val;
}
示例8: GetDatabaseFieldAttributeFromODT
/// <summary>
/// Liest die Werte von einem Attributs eines Datenquellen-verknüpften Feldes aus einer OpenDocument 1.2-basierter Datei aus
/// mögliche Attribute: text:table-name, text:column-name, text:database-name, text:table-type
/// </summary>
/// <param name="filePath">auszulesende Datei</param>
/// <param name="attribute">auszulesendes Attribut</param>
/// <returns>Liste von Strings</returns>
public static IEnumerable<string> GetDatabaseFieldAttributeFromODT(string filePath, string attribute)
{
IList<string> attributeValues = new List<string>();
try
{
using (ZipFile zip = ZipFile.Read(filePath))
{
using (var stream = zip["content.xml"].OpenReader())
{
using (var content = new StreamReader(stream))
{
using (var xmlReader = new XmlTextReader(content))
{
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element) // check for XML node
if (xmlReader.Name == "text:database-display") // this is the tag indicating a link to an db/csv value
while (xmlReader.MoveToNextAttribute()) // read its attributes
if (xmlReader.Name == attribute) // check if it is the attribute we are looking for
attributeValues.Add(xmlReader.Value);
}
return attributeValues;
}
}
}
}
}
catch
{
return attributeValues;
}
}
示例9: HandleFurnidata
public void HandleFurnidata(string[] items)
{
int count = 0;
int error = 0;
XmlTextReader reader = new XmlTextReader("figuremap.xml");
WebClient webClient = new WebClient();
string production = "";
Console.WriteLine("Name the SWF Build (for example: PRODUCTION-201507062205-18729)");
production = Console.ReadLine();
while(reader.Read())
{
if (reader.Name == "lib" && reader.NodeType == XmlNodeType.Element)
{
while (reader.MoveToNextAttribute())
{
int idk = 0;
if (reader.Name == "id" && !int.TryParse(reader.Value, out idk))
{
try
{
Console.Write("Downloading cloth " + reader.Value + " ");
Console.SetCursorPosition(0, Console.CursorTop);
webClient.DownloadFile("http://images-eussl.habbo.com/dcr/gordon/" + production + "/" + reader.Value + ".swf", "swfs/clothes/" + reader.Value + ".swf");
count++;
}
catch
{
error++;
}
}
}
}
}
Console.WriteLine("Finished (" + count + " successful, " + error + " errors)! Press the any key for the main menu.");
}
示例10: button1_Click
private void button1_Click(object sender, EventArgs e)
{
XmlTextReader tr =
new XmlTextReader(@"D:\MS.Net\CSharp\XMLParser\XMLParser\Emp.xml");
while (tr.Read())
{
//Check if it is a start tag
if (tr.NodeType == XmlNodeType.Element)
{
listBox1.Items.Add(tr.Name);
if (tr.HasAttributes)
{
tr.MoveToFirstAttribute();
string str = tr.Name;
str += " = ";
str += tr.Value;
listBox1.Items.Add(str);
}
if (tr.MoveToNextAttribute())
{
string str = tr.Name;
str += " = ";
str += tr.Value;
listBox1.Items.Add(str);
}
}
if (tr.NodeType == XmlNodeType.Text)
{
listBox1.Items.Add(tr.Value);
}
}
}
示例11: EnumerateAttributes
private int EnumerateAttributes(string elementStartTag, Action<int, int, string> onAttributeSpotted)
{
bool selfClosed = (elementStartTag.EndsWith("/>", StringComparison.Ordinal));
string xmlDocString = elementStartTag;
if (!selfClosed)
{
xmlDocString = elementStartTag.Substring(0, elementStartTag.Length-1) + "/>" ;
}
XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlDocString));
xmlReader.Namespaces = false;
xmlReader.Read();
bool hasMoreAttributes = xmlReader.MoveToFirstAttribute();
while (hasMoreAttributes)
{
onAttributeSpotted(xmlReader.LineNumber, xmlReader.LinePosition, xmlReader.Name);
hasMoreAttributes = xmlReader.MoveToNextAttribute();
}
int lastCharacter = elementStartTag.Length;
if (selfClosed)
{
lastCharacter--;
}
return lastCharacter;
}
示例12: Main
public static void Main(string[] args)
{
XmlTextReader xmlReader = new XmlTextReader ("Book.xml");
while(xmlReader.Read()){
switch (xmlReader.NodeType) {
case XmlNodeType.Element:
Console.WriteLine ("This is XmlNodeType.Element");
Console.Write ("<" + xmlReader.Name);
//Reading Attributes of XML Element
while (xmlReader.MoveToNextAttribute()) // Read the attributes.
Console.Write(" " + xmlReader.Name + "='" + xmlReader.Value + "'");
//
Console.WriteLine (">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine("This is xmlNodeType.Text");
Console.WriteLine (xmlReader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
Console.WriteLine("This is xmlNodeType.EndElement");
Console.Write("</" + xmlReader.Name);
Console.WriteLine(">");
break;
}
}
Console.WriteLine ("XMl Reading Has Completed");
}
示例13: Load
/// <summary>
/// TODO: Multiple spawns please.
/// </summary>
/// <param name="world"></param>
public static void Load(GameWorld world)
{
string path = Config.GetDataPath() + "world/spawns.xml";
XmlTextReader reader = new XmlTextReader(path);
Respawn currentRespawn = null;
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
while (reader.MoveToNextAttribute()) // Read attributes
{
if (reader.Name == "centerx") {
currentRespawn = new Respawn(world);
currentRespawn.CenterX = ushort.Parse(reader.Value);
} else if (reader.Name == "centery") {
currentRespawn.CenterY = ushort.Parse(reader.Value);
} else if (reader.Name == "centerz") {
currentRespawn.CenterZ = byte.Parse(reader.Value);
} else if (reader.Name == "radius") {
currentRespawn.Radius = int.Parse(reader.Value);
} else if (reader.Name == "name") {
currentRespawn.MonsterName = reader.Value;
} else if (reader.Name == "spawntime") {
if (currentRespawn.CanSpawn()) {
currentRespawn.Spawn();
}
//currentRespawn.SpawnTime = 100 * int.Parse(reader.Value);
}
}
break;
}
}
reader.Close();
}
示例14: loadXMLMap
/// <summary>Loads the map from the XML file</summary>
/// <param name="name">File name of the map</param>
public void loadXMLMap()
{
XmlTextReader reader = new XmlTextReader("maps/xml/" + id + ".tmx");
int i = 0;
int j = 0;
while (reader.Read())
{
// http://msdn.microsoft.com/fr-fr/library/9b9dty7d(VS.80).aspx
if (reader.NodeType == XmlNodeType.Element) // The node is an element.
{
while (reader.MoveToNextAttribute())
{ // Read the attributes.
if (reader.Name == "gid")
{
TabMap[i, j] = Convert.ToInt32(reader.Value);
if (i == 19)
{
i = 0;
j++;
}
else
{
i++;
}
}
}
}
}
}
示例15: local
/// <summary>
/// Sets the Language Content and reads it from an XML File.
/// </summary>
public void local(String s)
{
try
{
String sFilename = Directory.GetCurrentDirectory() + "/" + s;
XmlTextReader reader = new XmlTextReader(sFilename);
reader.Read();
reader.Read();
int count = 4;
String[] t = new String[count];
String[] t2 = new String[count];
for (int i = 0; i < count; i++)
{
reader.Read();
reader.Read();
t[i] = reader.Name;
reader.MoveToNextAttribute();
t2[i] = reader.Value;
if (t2[i] == "")
{
throw new XmlException("datei nicht lang genug");
}
}
label1.Content = t2[0];
label2.Content = t2[1];
label3.Content = t2[2];
tb1.Text = t2[3];
}
catch (IndexOutOfRangeException) { }
catch (FileNotFoundException) { }
catch (XmlException) { }
}