本文整理匯總了C#中System.Xml.XmlTextReader.MoveToAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.MoveToAttribute方法的具體用法?C# XmlTextReader.MoveToAttribute怎麽用?C# XmlTextReader.MoveToAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.MoveToAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ReadFromFile
private ArrayList ReadFromFile(string file)
{
ArrayList list = new ArrayList();
XmlReader reader = new XmlTextReader(file);
while (reader.Read())
{
if (reader.NodeType != XmlNodeType.Element)
continue;
if(string.Compare(reader.Name, @"data") != 0)
continue;
if (!reader.HasAttributes)
continue;
if(!reader.MoveToAttribute(@"xml:space"))
continue;
if (string.Compare(reader.Value, @"preserve") != 0)
continue;
if (!reader.MoveToAttribute("name"))
continue;
list.Add(reader.Value);
}
reader.Close();
return list;
}
示例2: MakeList
public List<Article> MakeList(params string[] searchCriteria)
{
List<Article> articles = new List<Article>();
using (
XmlTextReader reader =
new XmlTextReader(new StringReader(Tools.GetHTML(Common.GetUrlFor("displayarticles") + "&count=" + Count))))
{
while (reader.Read())
{
if (reader.Name.Equals("site"))
{
reader.MoveToAttribute("address");
string site = reader.Value;
if (site != Common.GetSite())
//Probably shouldnt get this as the wanted site was sent to the server
{
MessageBox.Show("Wrong Site");
}
}
else if (reader.Name.Equals("article"))
{
reader.MoveToAttribute("id");
int id = int.Parse(reader.Value);
string title = reader.ReadString();
articles.Add(new Article(title));
if (!TypoScanBasePlugin.PageList.ContainsKey(title))
TypoScanBasePlugin.PageList.Add(title, id);
}
}
}
TypoScanBasePlugin.CheckoutTime = DateTime.Now;
return articles;
}
示例3: Parse
private void Parse( XmlTextReader xml )
{
if ( xml.MoveToAttribute( "name" ) )
{
m_Name = xml.Value;
}
else
{
m_Name = "empty";
}
int x = 0, y = 0, z = 0;
if ( xml.MoveToAttribute( "x" ) )
{
x = Utility.ToInt32( xml.Value );
}
if ( xml.MoveToAttribute( "y" ) )
{
y = Utility.ToInt32( xml.Value );
}
if ( xml.MoveToAttribute( "z" ) )
{
z = Utility.ToInt32( xml.Value );
}
m_Location = new Point3D( x, y, z );
}
示例4: stworz_liste_plikow_xml
public string[] stworz_liste_plikow_xml()
{
//tworzenie listy plików z folderu do porównywarki.
string[] files = Directory.GetFiles(".", "top100_*.xml");
int i = 0;
string data = "", czas = "";
if (files.Length != 0)
{
foreach (string file in files)
{
XmlTextReader xtr = new XmlTextReader(file);
xtr.Read();
xtr.Read();
xtr.Read();
xtr.MoveToAttribute("data");
data = xtr.Value;
xtr.MoveToAttribute("godzina");
czas = xtr.Value;
plikiHistoriaKlasa[i] = file.ToString().Substring(2);
i++;
}
}
return plikiHistoriaKlasa;
}
示例5: Load
public void Load (string file, bool system)
{
XmlTextReader reader = new XmlTextReader (file);
string set_name = null;
List<string> counters = new List<string> ();
while (reader.Read ()) {
if (reader.NodeType == XmlNodeType.Element) {
string name = reader.Name;
if (name == "mperfmon")
continue;
if (name == "update") {
for (int i = 0; i < reader.AttributeCount; ++i) {
reader.MoveToAttribute (i);
if (reader.Name == "interval") {
timeout = uint.Parse (reader.Value);
}
}
continue;
}
if (name == "set") {
for (int i = 0; i < reader.AttributeCount; ++i) {
reader.MoveToAttribute (i);
if (reader.Name == "name") {
set_name = reader.Value;
}
}
continue;
}
if (name == "counter") {
string cat = null, counter = null;
for (int i = 0; i < reader.AttributeCount; ++i) {
reader.MoveToAttribute (i);
if (reader.Name == "cat") {
cat = reader.Value;
} else if (reader.Name == "name") {
counter = reader.Value;
}
}
if (cat != null && counter != null) {
counters.Add (cat);
counters.Add (counter);
}
continue;
}
} else if (reader.NodeType == XmlNodeType.EndElement) {
if (reader.Name == "set") {
sets.Add (new CounterSet (set_name, counters, system));
set_name = null;
counters.Clear ();
}
}
}
}
示例6: Currency
public Currency()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
try
{
xml = new XmlTextReader(sourceUrl); //tries to download XML file and create the Reader object
}
catch (WebException we) // if download is imposible, creates defalt value for BGN and EUR and throws an exception
{
this.baseCurrency = "EUR";
this.exchangeRates.Add(this.baseCurrency, 1M);
this.exchangeRates.Add("BGN", 1.9558M);
this.date = DateTime.Now;
throw new WebException("Error downloading XML, exchange rate created for BGN only, base currency EUR!", we);
}
try
{
while (xml.Read())
{
if (xml.Name == "Cube")
{
if (xml.AttributeCount == 1)
{
xml.MoveToAttribute("time");
this.date = DateTime.Parse(xml.Value); // gets the date on which this rates are valid
}
if (xml.AttributeCount == 2)
{
xml.MoveToAttribute("currency");
this.currency = xml.Value;
xml.MoveToAttribute("rate");
try
{
this.rate = decimal.Parse(xml.Value);
}
catch (FormatException fe)
{
throw new FormatException("Urecognised format!", fe);
}
this.exchangeRates.Add(currency, rate); //ads currency and rate to exchange rate table
}
xml.MoveToNextAttribute();
}
}
}
catch (XmlException xe)
{
throw new XmlException("Unable to parse Euro foreign exchange reference rates XML!", xe);
}
this.baseCurrency = "EUR"; // if XML parsed, add base currency
this.exchangeRates.Add(this.baseCurrency, 1M);
}
示例7: CAGObject
public CAGObject( CAGCategory parent, XmlTextReader xml )
{
m_Parent = parent;
if ( xml.MoveToAttribute( "type" ) )
m_Type = ScriptCompiler.FindTypeByFullName( xml.Value, false );
if ( xml.MoveToAttribute( "gfx" ) )
m_ItemID = XmlConvert.ToInt32( xml.Value );
if ( xml.MoveToAttribute( "hue" ) )
m_Hue = XmlConvert.ToInt32( xml.Value );
}
示例8: CreateLookup
public void CreateLookup(SPFeatureReceiverProperties properties, SPWeb web, String filePath)
{
string fieldId;
bool isReading = true;
XmlDocument document = GetXmlDocument(properties.Definition, filePath, web.Locale);
using (XmlTextReader reader = new XmlTextReader(new StringReader(document.OuterXml)))
{
CreateListMapping(properties);
while (true)
{
if (reader.LocalName != "Field" || isReading)
{
if (!reader.Read())
{
break;
}
}
if (reader.LocalName == "Field")
{
if (reader.MoveToAttribute("Type") &&
reader.Value == "Lookup" &&
reader.MoveToAttribute("Name"))
{
fieldId = reader.Value;
if (lookupsListMapping.ContainsKey(fieldId))
{
String listName = lookupsListMapping[fieldId];
SPList list = GetListForLookup(listName, web);
reader.MoveToContent();
XmlDocument doc = new XmlDocument();
String fieldElement = reader.ReadOuterXml();
doc.LoadXml(fieldElement);
XPathNavigator navigator = doc.DocumentElement.CreateNavigator();
navigator.CreateAttribute("", "List", "", list.ID.ToString());
SPFieldLookup field = (SPFieldLookup)web.Fields[fieldId];
AddWebIdAttribute(web, doc);
field.SchemaXml = RemoveXmlnsAttribute(doc.OuterXml);
field.Update(true);
isReading = false;
continue;
}
}
}
isReading = true;
}
}
}
示例9: LoadConfiguration
public void LoadConfiguration(String configFilePath)
{
// Load the config file
XmlTextReader xmlReader = null;
try
{
xmlReader = new XmlTextReader(configFilePath);
// Read all the infos
while (xmlReader.Read())
{
xmlReader.MoveToContent();
if (xmlReader.NodeType == XmlNodeType.Element)
{
switch (xmlReader.Name)
{
case "TorrentSrcDirectory":
xmlReader.MoveToAttribute("path");
m_torrentSrcDirector = xmlReader.Value;
break;
case "TVShowDirectory":
xmlReader.MoveToAttribute("path");
m_tvShowDirectory = xmlReader.Value;
break;
case "FileExtensions":
xmlReader.MoveToAttribute("value");
m_fileExtensions = xmlReader.Value;
break;
case "TVShow":
TVShow tvShow = new TVShow();
ReadTVShowInfos(xmlReader, tvShow);
m_tvShows.Add(tvShow);
break;
}
}
}
}
catch (Exception e)
{
Program.LogMessageToFile(String.Format("Unable to process configuration file, {0}", e.ToString()));
}
finally
{
if (xmlReader != null)
xmlReader.Close();
}
}
示例10: Parse
private void Parse( XmlTextReader xml )
{
if ( xml.MoveToAttribute( "name" ) )
m_Name = xml.Value;
else
m_Name = "empty";
if ( xml.IsEmptyElement )
{
m_Children = new object[0];
}
else
{
ArrayList children = new ArrayList();
while ( xml.Read() && xml.NodeType == XmlNodeType.Element )
{
if ( xml.Name == "child" )
{
ChildNode n = new ChildNode( xml, this );
children.Add( n );
}
else
{
children.Add( new ParentNode( xml, this ) );
}
}
m_Children = children.ToArray();
}
}
示例11: ReadXMLFile
public void ReadXMLFile()
{
XmlTextReader xmlReader = null;
try
{
string strPath = "C:\\temp\\kai\\Rules\\Russian_1.xml";
xmlReader = new XmlTextReader (strPath);
while (xmlReader.Read())
{
if (XmlNodeType.Element == xmlReader.NodeType)
{
sCurrentElement = xmlReader.Name;
int nAttr = xmlReader.AttributeCount;
for (int iAttr = 0; iAttr < nAttr; ++iAttr)
{
xmlReader.MoveToAttribute (iAttr);
string sAttr = xmlReader.Name;
// int ggg = 0;
}
} // if
} // while...
} // try
catch
{
int ggg = 0;
}
finally
{
xmlReader.Close();
}
}
示例12: MakeList
public List<Article> MakeList(params string[] searchCriteria)
{
List<Article> articles = new List<Article>();
// TODO: must support other wikis
if (Variables.Project != ProjectEnum.wikipedia || Variables.LangCode != LangCodeEnum.en)
{
MessageBox.Show("This plugin currently supports only English Wikipedia",
"TypoScan", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return articles;
}
for (int i = 0; i < Iterations; i++)
{
using (
XmlTextReader reader =
new XmlTextReader(new StringReader(Tools.GetHTML(Common.GetUrlFor("displayarticles")))))
{
while (reader.Read())
{
if (reader.Name.Equals("article"))
{
reader.MoveToAttribute("id");
int id = int.Parse(reader.Value);
string title = reader.ReadString();
articles.Add(new Article(title));
if (!TypoScanAWBPlugin.PageList.ContainsKey(title))
TypoScanAWBPlugin.PageList.Add(title, id);
}
}
}
}
TypoScanAWBPlugin.CheckoutTime = DateTime.Now;
return articles;
}
示例13: LoadLogs
public bool LoadLogs(String[] uris)
{
try
{
foreach (String uri in uris)
{
XML = new XmlTextReader(uri);
while (XML.Read())
{
Console.Write("loading log");
if (XML.Name == "PointingMagnifier")
{
p.ReadLog(XML);
}
if (XML.HasAttributes)
{
for (int i = 0; i < XML.AttributeCount; i++)
{
XML.MoveToAttribute(i);
}
}
}
}
}
catch
{
return false;
}
lblNumStates.Text = String.Format("States: {0}", p.NumStates());
lblNumEvents.Text = String.Format("Events: Active - {0}, Inactive - {1}", p.NumActiveEvents(), p.NumNonActiveEvents());
return true;
}
示例14: CAGCategory
public CAGCategory( CAGCategory parent, XmlTextReader xml )
{
m_Parent = parent;
if ( xml.MoveToAttribute( "title" ) )
m_Title = xml.Value;
else
m_Title = "empty";
if ( m_Title == "Docked" )
m_Title = "Docked 2";
if ( xml.IsEmptyElement )
{
m_Nodes = new CAGNode[0];
}
else
{
ArrayList nodes = new ArrayList();
/*while ( xml.Read() && xml.NodeType != XmlNodeType.EndElement )
{
if ( xml.NodeType == XmlNodeType.Element && xml.Name == "object" )
nodes.Add( new CAGObject( this, xml ) );
else if ( xml.NodeType == XmlNodeType.Element && xml.Name == "category" )
nodes.Add( new CAGCategory( this, xml ) );
else
xml.Skip();
}*/
m_Nodes = (CAGNode[])nodes.ToArray( typeof( CAGNode ) );
}
}
示例15: readCurrentElement
/// <summary>
/// Parser recursiv de elemente XML.
/// </summary>
/// <param name="reader">Cititorul secvenţial care a deschis fişierul XML</param>
/// <returns>Elementul XML parsat care conţine toate atributele şi subelementele sale</returns>
private static XMLElement readCurrentElement(XmlTextReader reader)
{
if (!reader.IsStartElement()) {
return null;
}
bool hasChildren = !reader.IsEmptyElement;
XMLElement result = new XMLElement();
for (int i = 0; i < reader.AttributeCount; ++i) {
reader.MoveToAttribute(i);
result.addAttribute(reader.Name, reader.Value);
}
if (hasChildren) {
while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) {
if (reader.IsStartElement()) {
result.addElement(reader.Name, readCurrentElement(reader));
}
}
}
reader.Read();
return result;
}