本文整理汇总了C#中System.Xml.XmlDocument.GetElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.GetElementsByTagName方法的具体用法?C# XmlDocument.GetElementsByTagName怎么用?C# XmlDocument.GetElementsByTagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.GetElementsByTagName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnOpenFile_Click
private void btnOpenFile_Click( object sender, EventArgs e )
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "BackupGuy Path Tree Files (*.bpt)|*.bpt|All Files(*.*)|*.*";
if( ofd.ShowDialog() == DialogResult.OK ) {
tbOpenFilePath.Text = ofd.FileName;
Document = new XmlDocument();
try {
Document.Load( ofd.FileName );
if( Document.GetElementsByTagName( "PathTree" ).Count > 0 ) {
comboLeftSource.Items.Add( "Left" );
comboRightSource.Items.Add( "Left" );
} else if( Document.GetElementsByTagName( "PathTreePair" ).Count > 0 ) {
comboLeftSource.Items.Add( "Left" );
comboLeftSource.Items.Add( "Right" );
comboRightSource.Items.Add( "Left" );
comboRightSource.Items.Add( "Right" );
} else {
throw new Exception();
}
} catch {
MessageBox.Show( "�ĵ���ʽ����ȷ��" );
Document = null;
}
SetControlsEnabled();
}
}
示例2: CheckMarkerPaths
public void CheckMarkerPaths(string fileName)
{
DirectoryInfo markerDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(fileName), "Markers"));
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
if (doc.GetElementsByTagName("markers").Count == 0) return;
XmlNodeList markerList = doc.GetElementsByTagName("marker");
if (markerList.Count > 0)
{
foreach (XmlNode node in markerList)
{
if(node.Attributes == null || node.Attributes["id"] == null)
throw new UserMessageException("Marker id doesn't exist for 'Marker' element in file {1}", fileName);
if (node.Attributes == null || node.Attributes["name"] == null)
throw new UserMessageException("Marker name doesn't exist for 'Marker' element in file {1}", fileName);
string id = node.Attributes["id"].Value;
string name = node.Attributes["name"].Value;
FileInfo[] f = markerDir.GetFiles(string.Format("{0}.*", id), SearchOption.TopDirectoryOnly);
if (f.Length == 0)
{
throw new UserMessageException("Marker image not found with id {0} and name {1} in file {2}", id, name, fileName);
}
}
}
doc.RemoveAll();
doc = null;
}
示例3: LoadXML
private void LoadXML()
{
XmlDocument xml = new XmlDocument();
try
{
xml.Load(path);
string Temp = xml.GetElementsByTagName("t")[0].InnerText;
string Cloud = xml.GetElementsByTagName("cloud")[0].InnerText;
string H = xml.GetElementsByTagName("h")[0].InnerText;
string Wind = xml.GetElementsByTagName("w")[0].InnerText;
string Pressure = xml.GetElementsByTagName("p")[0].InnerText;
tempLabel.Text = "Температура: " + Temp + "°C";
wetLabel.Text = "Влажность: " + H + "%";
windySpeedLabel.Text = "Скорость ветра: " + Wind + "м/с";
pressureLabel.Text = "Давление: " + Pressure + "мм";
cloudyLabel.Text = "Облачность: " + Cloud + "%";
}
catch (WebException exception)
{
tempLabel.Text = "N/A";
cloudyLabel.Text = "N/A";
wetLabel.Text = "N/A";
windySpeedLabel.Text = "N/A";
pressureLabel.Text = "N/A";
MessageBox.Show(exception.Message);
}
}
示例4: download_DownloadFileCompleted
public void download_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
XmlDocument current = new XmlDocument();
current.Load(Environment.CurrentDirectory + @"\Info.xml");
XmlNodeList pro = current.GetElementsByTagName("ProgramName");
XmlNodeList update = current.GetElementsByTagName("updatexml");
string prog = pro[0].InnerText;
string updateurl = update[0].InnerText;
XmlDocument updater = new XmlDocument();
updater.Load(updateurl);
XmlNodeList load = updater.GetElementsByTagName("InstallerNAME");
string installer = load[0].InnerText;
if (bytesIn == totalBytes)
{
MessageBox.Show("Update has been downloaded sucessfully. Please Close all instances of " + prog + " while update is in session.", "Update Complete");
System.Diagnostics.Process.Start(path + @"\" + installer);
}
else if (bytesIn != totalBytes)
{
MessageBox.Show("Update Canceled", "!WARNING!");
System.IO.File.Delete(path + @"\" + installer);
}
Application.Exit();
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
this.btnOK.Click += new EventHandler(this.btnOK_Click);
if (!base.IsPostBack)
{
SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
this.radEnableWapShengPay.SelectedValue = masterSettings.EnableWapShengPay;
PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("Hishop.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest");
if (paymentMode != null)
{
string xml = HiCryptographer.Decrypt(paymentMode.Settings);
XmlDocument document = new XmlDocument();
document.LoadXml(xml);
try
{
this.txtPartner.Text = document.GetElementsByTagName("SenderId")[0].InnerText;
this.txtKey.Text = document.GetElementsByTagName("SellerKey")[0].InnerText;
}
catch
{
this.txtPartner.Text = "";
this.txtKey.Text = "";
}
}
PaymentModeInfo info2 = SalesHelper.GetPaymentMode("Hishop.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest");
if (info2 != null)
{
string str2 = HiCryptographer.Decrypt(info2.Settings);
new XmlDocument().LoadXml(str2);
}
}
}
示例6: Level
public Level(ref StreamReader s, XmlDocument xml)
{
paused = false;
ticker = 80;
var xlevelnum = xml.GetElementsByTagName("LevelNum");
int xmlLvl = Convert.ToInt32(xlevelnum.Item(0).Value);
XmlNodeList roomXMLs = xml.GetElementsByTagName("Room");
Room room1 = new Room(roomXMLs.Item(0));
if ((line = s.ReadLine()) != null)
levelNum = Convert.ToInt32(line);
rooms = new Room[cellNum, cellNum];
roomMap = new roomState[cellNum, cellNum];
int numRooms = Convert.ToInt32(s.ReadLine());
initialRoom = new Vector2(Convert.ToInt64(s.ReadLine()), Convert.ToInt64(s.ReadLine()));
for (int i = 0; i < cellNum; i++) {
for (int j = 0; j < cellNum; j++)
rooms[i, j] = null;
}
while(numRooms > 0){
int x = Convert.ToInt32(s.ReadLine());
int y = Convert.ToInt32(s.ReadLine());
rooms[x, y] = new Room(ref s, x, y);
roomMap[x, y] = roomState.notVisited;
numRooms--;
}
}
示例7: Fetch
//Method to take a signed URL and return information contained in the get response
public static string Fetch(string url)
{
string asin = "";
try {
//Makes a request, and exports the response into an XML file
WebRequest request = HttpWebRequest.Create(url);
WebResponse response = request.GetResponse();
XmlDocument doc = new XmlDocument();
doc.Load(response.GetResponseStream());
//Parse XML document for errors
XmlNodeList errorMessageNodes = doc.GetElementsByTagName("Message", NAMESPACE);
if (errorMessageNodes != null && errorMessageNodes.Count > 0) {
String message = errorMessageNodes.Item(0).InnerText;
string error;
MessageBox.Show("Unfortunately, music preview isn't available for this track.");
//MessageBox.Show("Error: " + message + " (but signature worked)");
return null;
}
XmlNode asinNode = doc.GetElementsByTagName("ASIN", NAMESPACE).Item(0);
if (asinNode != null) asin = asinNode.InnerText;
return asin;
}
catch (Exception e) {
System.Console.WriteLine("Caught Exception: " + e.Message);
System.Console.WriteLine("Stack Trace: " + e.StackTrace);
}
return null;
}
示例8: Auth
private void Auth()
{
string mpopdata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><AutoLogin ProjectId=\"11321\" SubProjectId=\"0\" ShardId=\"0\" Mpop=\""+tokenmpop+"\"/>";
HttpWebRequest myWebRequest2 = (HttpWebRequest)WebRequest.Create(@"https://authdl.mail.ru/sz.php?hint=AutoLogin");
myWebRequest2.ContentType = "application/x-www-form-urlencoded";
myWebRequest2.Method = "POST";
myWebRequest2.UserAgent = "Downloader/11450";
// myWebRequest2.CookieContainer = myCookie;
byte[] mpoppostbyte = Encoding.UTF8.GetBytes(mpopdata);
Stream MyRequest2 = myWebRequest2.GetRequestStream();
MyRequest2.Write(mpoppostbyte, 0, mpoppostbyte.Length);
MyRequest2.Close();
HttpWebResponse myResponse2 = (HttpWebResponse)myWebRequest2.GetResponse();
Stream myStream = myResponse2.GetResponseStream();
StreamReader sr = new StreamReader(myStream);
String myRespString = sr.ReadToEnd();
myResponse2.Close();
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(myRespString);
string myAPersId = xmldoc.GetElementsByTagName("AutoLogin").Item(0).Attributes["PersId"].Value;
string myAKey = xmldoc.GetElementsByTagName("AutoLogin").Item(0).Attributes["Key"].Value;
Environment.SetEnvironmentVariable("GC_PROJECT_ID", "11321");
Environment.SetEnvironmentVariable("GC_TYPE_ID", "0");
lStat.Text = "Запуск игры";
Application.DoEvents();
System.Threading.Thread.Sleep(5000);
Process Armata = Process.Start("ArmoredWarfare.exe", " --sz_pers_id=" + myAPersId + " --sz_token=" + myAKey);
System.Threading.Thread.Sleep(5000);
lStat.Text = "Играем";
Armata.EnableRaisingEvents = true;
Armata.Exited += new EventHandler(Armata_Exited);
}
示例9: GetSignatureElement
private XmlElement GetSignatureElement(XmlDocument doc, string signatureNamespaceUrl, string parent)
{
XmlNodeList nodeList = null;
if (string.IsNullOrEmpty(signatureNamespaceUrl))
{
nodeList = doc.GetElementsByTagName("Signature");
}
else
{
nodeList = doc.GetElementsByTagName("Signature", signatureNamespaceUrl);
}
XmlElement sigElem = null;
if (nodeList.Count == 1)
{
sigElem = (XmlElement)nodeList[0];
}
else
{
sigElem = GetMainSignatureElement(nodeList, parent);
}
return sigElem;
}
示例10: RemoveSoundNodes
private static void RemoveSoundNodes(string ovfFile)
{
var xdoc = new XmlDocument();
xdoc.Load(ovfFile);
//<rasd:ElementName><Item><VirtualHardwareSection> <VirtualSystem ovf:id="Centos65_x64_OpenERP"> <Envelope
var parentNode = xdoc.GetElementsByTagName("VirtualHardwareSection").Item(0);
var node = xdoc.GetElementsByTagName("Item");
// xdoc.SelectNodes("/Envelope/VirtualSystem/VirtualHardwareSection/Item/rasd:ElementName");
var needDelList = new List<XmlElement>();
foreach (XmlElement n in node)
{
var childs = n.GetElementsByTagName("rasd:ElementName");
if (childs.Count > 0)
{
if (childs[0].InnerText.Trim().ToUpper() == "sound".ToUpper())
{
needDelList.Add(n);
}
}
}
foreach (var element in needDelList)
{
parentNode.RemoveChild(element);
}
xdoc.Save(ovfFile);
}
示例11: processTrxFile
public TestResultCollection processTrxFile(string fileName, bool publishFailures, bool PublishErrorInformation)
{
TestResultCollection resultCollection = new TestResultCollection();
//Holds the contents of the trx file
string trxFileContents;
//Read out the contents of the trx file
using (StreamReader trxReader = new StreamReader(fileName))
{
trxFileContents = trxReader.ReadToEnd();
trxReader.Close();
}
//Load the file contents into an XML document object
XmlDocument trxFileXml = new XmlDocument();
trxFileXml.LoadXml(trxFileContents);
//Configure the namespace manager
XmlNamespaceManager xmlManager = new XmlNamespaceManager(trxFileXml.NameTable);
xmlManager.AddNamespace("ns", "http://microsoft.com/schemas/VisualStudio/TeamTest/2006");
//Get the list of unit test result nodes
XmlNodeList resultNodes = trxFileXml.GetElementsByTagName("UnitTestResult");
resultCollection.Append(ProcessResultsNode(resultNodes, publishFailures, PublishErrorInformation));
//Now do the same for Manual tests
resultNodes = trxFileXml.GetElementsByTagName("ManualTestResult");
resultCollection.Append(ProcessResultsNode(resultNodes, publishFailures, PublishErrorInformation));
XmlNodeList definitionNodes = trxFileXml.GetElementsByTagName("TestDefinitions");
AddWorkItemsToResults(resultCollection, trxFileXml);
AddExecutionUserToResults(resultCollection, trxFileXml);
return resultCollection;
}
示例12: button1_Click
private void button1_Click(object sender, System.EventArgs e)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load("sampleXML.xml"); //File is located in the "\bin\Debug" folder
XmlNodeList name = xDoc.GetElementsByTagName("myName");
XmlNodeList telephone = xDoc.GetElementsByTagName("myTelephone");
XmlNodeList email = xDoc.GetElementsByTagName("myEmail");
XmlNodeList age = xDoc.GetElementsByTagName("myAge");
XmlNodeList sex = xDoc.GetElementsByTagName("mySex");
MessageBox.Show(
"Name: " + name[0].InnerText +"\n"+
"Telephone: " + telephone[0].InnerText +"\n"+
"Email: "+ email[0].InnerText +"\n"+
"Age: "+ age[0].InnerText +"\n"+
"sex: "+ sex[0].InnerText +"\n"
);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
示例13: wczytajUstawienia
public void wczytajUstawienia()
{
if(_ustawieniaWczytane)
return;
_ustawieniaWczytane = true;
XmlDocument plikXML = new XmlDocument();
plikXML.Load(@"C:\museSort\config.xml");
var xmlNode = plikXML.GetElementsByTagName("folderGlowny").Item(0);
if (xmlNode != null) folderGlowny = xmlNode.InnerText;
xmlNode = plikXML.GetElementsByTagName("domyslneSortowanieMuzyki").Item(0);
if (xmlNode != null) domyslneSortowanieMuzyki = xmlNode.InnerText;
xmlNode = plikXML.GetElementsByTagName("domyslneSortowanieFilmow").Item(0);
if (xmlNode != null && xmlNode.InnerText!="") domyslneSortowanieFilmow = xmlNode.InnerText;
foreach (XmlNode x in plikXML.GetElementsByTagName("rozszerzenieAudio"))
{
wspieraneRozszerzeniaAudio.Add(x.InnerText);
}
foreach (XmlNode x in plikXML.GetElementsByTagName("rozszerzenieVideo"))
{
wspieraneRozszerzeniaVideo.Add(x.InnerText);
}
Film.wczytajWzorceZPliku(@"C:\museSort\config.xml");
Utwor.wczytajWzorceZPliku(@"C:\museSort\config.xml");
}
示例14: PopulaGridInutilizados
private void PopulaGridInutilizados()
{
try
{
DirectoryInfo diretorio = new DirectoryInfo(sPastaProtocolos);
FileSystemInfo[] itens = diretorio.GetFileSystemInfos("*.xml");
int irow = 0;
dgvInutilizacoes.Rows.Clear();
foreach (FileSystemInfo item in itens)
{
if ((item.Name.Contains("_inu")) && (!item.Name.Contains("_ped_inu")))
{
XmlDocument xml = new XmlDocument();
xml.Load(item.FullName);
dgvInutilizacoes.Rows.Add();
dgvInutilizacoes[0, irow].Value = (xml.GetElementsByTagName("tpAmb").Item(0).InnerText == "2" ? "Homologação" : "Produção");
dgvInutilizacoes[1, irow].Value = xml.GetElementsByTagName("nNFIni").Item(0).InnerText.PadLeft(9, '0');
dgvInutilizacoes[2, irow].Value = xml.GetElementsByTagName("nNFFin").Item(0).InnerText.PadLeft(9, '0');
dgvInutilizacoes[3, irow].Value = Convert.ToDateTime(xml.GetElementsByTagName("dhRecbto").Item(0).InnerText).ToString("dd/MM/yyyy");
dgvInutilizacoes[4, irow].Value = xml.GetElementsByTagName("nProt").Item(0).InnerText;
irow++;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
示例15: Battle
public Battle(SPRWorld sprWorld, int botHalfWidth, World world, int currentLevel)
{
this.sprWorld = sprWorld;
this.botHalfWidth = botHalfWidth;
this.world = world;
xmlDoc = new XmlDocument();
if (nextAllies == "")
{
xmlDoc.Load("Games/SuperPowerRobots/Storage/Allies.xml");
}
else
{
xmlDoc.LoadXml(nextAllies);
}
//xmlDoc.
XmlNodeList nodes = xmlDoc.GetElementsByTagName("Bot");
Vector2[] edges = { new Vector2(-botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, botHalfWidth) * Settings.MetersPerPixel, new Vector2(-botHalfWidth, botHalfWidth) * Settings.MetersPerPixel };
CreateBots(nodes, edges);
xmlDoc.Load("Games/SuperPowerRobots/Storage/Battles.xml");
nodes = xmlDoc.GetElementsByTagName("Level");
nodes = nodes[currentLevel].ChildNodes;
CreateBots(nodes, edges);
}