本文整理汇总了C#中System.Xml.XmlDocument.SelectNodes方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.SelectNodes方法的具体用法?C# System.Xml.XmlDocument.SelectNodes怎么用?C# System.Xml.XmlDocument.SelectNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.SelectNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGamesIni
public static void CreateGamesIni(string inputXML,string gamesIniPath)
{
//string filename = args[0];
//Console.WriteLine(filename);
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(inputXML);
var di = new DirectoryInfo(gamesIniPath);
var fi = new FileInfo(gamesIniPath + "\\games.ini");
di.Attributes &= FileAttributes.Normal;
if (File.Exists(fi.FullName))
fi.Attributes &= ~FileAttributes.ReadOnly;
using (System.IO.StreamWriter file = new System.IO.StreamWriter(gamesIniPath + "\\games.ini", true))
{
file.WriteLine("# This file is only used for remapping specific games to other Emulators and/or Systems.");
file.WriteLine("# If you don't want your game to use the Default_Emulator, you would set the Emulator key here.");
file.WriteLine("# This file can also be used when you have Wheels with games from other Systems.");
file.WriteLine("# You would then use the System key to tell HyperLaunch what System to find the emulator settings.");
file.WriteLine("");
}
foreach (System.Xml.XmlNode node in xdoc.SelectNodes("menu/game"))
{
string GameName = node.SelectSingleNode("@name").InnerText;
string sysName = node.SelectSingleNode("System").InnerText;
using (System.IO.StreamWriter file = new System.IO.StreamWriter(gamesIniPath + "\\games.ini", true))
{
file.WriteLine("[{0}]", GameName);
file.WriteLine(@"System={0}", sysName);
}
}
}
示例2: ListTables
public System.Collections.Generic.IEnumerable<Table> ListTables(string xmsclientrequestId = null)
{
List<Table> lTables = new List<Table>();
string strResult = Internal.InternalMethods.QueryTables(AccountName, SharedKey, UseHTTPS, xmsclientrequestId);
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
using (System.Xml.XmlReader re = System.Xml.XmlReader.Create(new System.IO.StringReader(strResult)))
{
doc.Load(re);
}
System.Xml.XmlNamespaceManager man = new System.Xml.XmlNamespaceManager(doc.NameTable);
man.AddNamespace("f", "http://www.w3.org/2005/Atom");
man.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
man.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
foreach (System.Xml.XmlNode n in doc.SelectNodes("//f:feed/f:entry", man))
{
yield return new Table()
{
AzureTableService = this,
Url = new Uri(n.SelectSingleNode("f:id", man).InnerText),
Name = n.SelectSingleNode("f:content/m:properties/d:TableName", man).InnerText
};
}
}
示例3: menuitem_Click
void menuitem_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog of = new System.Windows.Forms.OpenFileDialog();
of.DefaultExt = ".xml";
of.Filter = "XMLファイル(*.xml)|*.xml";
if (of.ShowDialog((System.Windows.Forms.IWin32Window)_host.Win32WindowOwner) == System.Windows.Forms.DialogResult.OK) {
try {
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(of.FileName);
// 擬似的に放送に接続した状態にする
_host.StartMockLive("lv0", System.IO.Path.GetFileNameWithoutExtension(of.FileName), DateTime.Now);
// ファイル内のコメントをホストに登録する
foreach (System.Xml.XmlNode node in xdoc.SelectNodes("packet/chat")) {
Hal.OpenCommentViewer.Control.OcvChat chat = new Hal.OpenCommentViewer.Control.OcvChat(node);
_host.InsertPluginChat(chat);
}
_host.ShowStatusMessage("インポートに成功しました。");
}catch(Exception ex){
NicoApiSharp.Logger.Default.LogException(ex);
_host.ShowStatusMessage("インポートに失敗しました。");
}
}
}
示例4: ListQueues
public List<Queue> ListQueues(
string prefix = null,
bool IncludeMetadata = false,
int timeoutSeconds = 0,
Guid? xmsclientrequestId = null)
{
List<Queue> lQueues = new List<Queue>();
string strNextMarker = null;
do
{
string sRet = Internal.InternalMethods.ListQueues(UseHTTPS, SharedKey, AccountName, prefix, strNextMarker,
IncludeMetadata: IncludeMetadata, timeoutSeconds: timeoutSeconds, xmsclientrequestId: xmsclientrequestId);
//Microsoft.SqlServer.Server.SqlContext.Pipe.Send("After Internal.InternalMethods.ListQueues = " + sRet);
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
using (System.IO.StringReader sr = new System.IO.StringReader(sRet))
{
doc.Load(sr);
}
foreach (System.Xml.XmlNode node in doc.SelectNodes("EnumerationResults/Queues/Queue"))
{
lQueues.Add(Queue.ParseFromXmlNode(this, node));
};
strNextMarker = doc.SelectSingleNode("EnumerationResults/NextMarker").InnerText;
//Microsoft.SqlServer.Server.SqlContext.Pipe.Send("strNextMarker == " + strNextMarker);
} while (!string.IsNullOrEmpty(strNextMarker));
return lQueues;
}
示例5: ReadGoofs
/// <summary>
/// Retrieves list of goofs from specified xml file
/// </summary>
/// <param name="xmlPath">path of xml file to read from</param>
public IList<IIMDbGoof> ReadGoofs(
string xmlPath)
{
try
{
List<IIMDbGoof> goofs = new List<IIMDbGoof>();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(xmlPath);
System.Xml.XmlNodeList goofList = doc.SelectNodes("/Goofs/Goof");
if (goofList != null)
foreach (System.Xml.XmlNode goofNode in goofList)
{
if (goofNode["Category"] != null
&& goofNode["Category"].InnerText != null
&& goofNode["Category"].InnerText.Trim() != ""
&& goofNode["Description"] != null
&& goofNode["Description"].InnerText != null
&& goofNode["Description"].InnerText.Trim() != "")
{
IMDbGoof goof = new IMDbGoof();
goof.Category = goofNode["Category"].InnerText;
goof.Description = goofNode["Description"].InnerText;
goofs.Add(goof);
}
}
return goofs;
}
catch (Exception ex)
{
throw ex;
}
}
示例6: LuceneSearchService
public LuceneSearchService(string Searchterm)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
string xpath = "[@name='MyArticles']";
this._searchterm = Searchterm;
doc.Load(HttpRuntime.AppDomainAppPath + "/App_Data/xml/indexConfig.xml");
this._indexConfigNodes = doc.SelectNodes("/indexConfiguration/*" + xpath);
if (Searchterm.StartsWith("§§INDEX§§")) this.IndexFiles(); else this.SearchIndex();
}
示例7: Parse
public static RetEntity Parse(string ret) {
var entity = new RetEntity();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(ret);
entity.Result = doc.DocumentElement.GetAttribute("result");
entity.Method = doc.DocumentElement.GetAttribute("name");
foreach (System.Xml.XmlNode node in doc.SelectNodes("//Item")) {
entity.Messages.Add(Message.Parse(node));
};
return entity;
}
示例8: LoadModules
public static void LoadModules()
{
string dir = AppDomain.CurrentDomain.BaseDirectory + "modules.config";
var doc = new System.Xml.XmlDocument();
doc.Load(dir);
var nodeList = doc.SelectNodes("Assemblys/Assembly");
foreach (System.Xml.XmlNode item in nodeList)
{
string dllPath = AppDomain.CurrentDomain.BaseDirectory + item.Attributes.GetNamedItem("path").Value;
Assembly target = Assembly.LoadFile(dllPath);
BuildManager.AddReferencedAssembly(target);
}
}
示例9: LoadControl
private static void LoadControl()
{
System.Xml.XmlDocument _document = new System.Xml.XmlDocument();
_document.Load(Xy.Tools.IO.File.foundConfigurationFile("App", Xy.AppSetting.FILE_EXT));
foreach (System.Xml.XmlNode _item in _document.SelectNodes("AppSetting/Controls/Control")) {
string _name = _item.Attributes["Name"].InnerText;
string _assembly = _item.Attributes["Type"].InnerText;
if (string.IsNullOrEmpty(_name) || string.IsNullOrEmpty(_assembly)) throw new System.Xml.XmlException("Control format error");
Add(_name, _assembly);
if (_item.HasChildNodes) {
_config.Add(_name, _item.ChildNodes);
}
}
}
示例10: InitializeCountersFromSettings
/// <summary>
/// Build counters by reading settings file
/// </summary>
private void InitializeCountersFromSettings()
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(ConfigurationManager.AppSettings["settingsFile"]);
// Création des compteurs
foreach (System.Xml.XmlNode monitor in doc.SelectNodes("/Monitor/*"))
{
switch (monitor.Attributes["type"].Value)
{
case "predefined":
switch (monitor.Attributes["value"].Value)
{
case "CPU":
CreateCPU();
break;
case "VirtualMemory":
CreateVirtualMemory();
break;
case "PhysicalMemory":
CreatePhysicalMemory();
break;
case "Network":
CreateNetwork();
break;
case "Disk":
CreateDisk();
break;
case "CPUFrequency":
CreateCPUFrequency();
break;
default:
throw new Exception(String.Format("value {0} unknown", monitor.Attributes["value"].Value));
}
break;
case "perfmon":
CreateSpecific(monitor.Attributes["value"].Value);
break;
default:
throw new Exception(String.Format("type {0} unknown", monitor.Attributes["type"].Value));
}
}
}
示例11: Form1
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
System.Xml.XmlDocument Doc = new System.Xml.XmlDocument();
Doc.Load("c:\\Controles.xml");
System.Xml.XmlNodeList lista;
lista = Doc.SelectNodes(@"//Control");
System.Xml.XmlElement e;
string clase, top, heigh, left, width, text;
//Assembly objAssembly=System.Reflection.Assembly.LoadFrom("C:\\Windows\\Microsoft.NET\\Framework\\v1.1.4322\\System.Windows.Forms.dll");
Assembly objAssembly = Assembly.LoadWithPartialName("System.Windows.Forms");
Object b;
for (int i=0; i < lista.Count; i++)
{
e = (System.Xml.XmlElement)lista[i];
clase = e.GetAttribute("clase");
top = e.GetAttribute("top");
heigh = e.GetAttribute("height");
left = e.GetAttribute("left");
width = e.GetAttribute("width");
text = e.GetAttribute("text");
Type t = objAssembly.GetType(clase);
//b = Activator.CreateInstance(t);
b = t.InvokeMember("", BindingFlags.CreateInstance, null, null, null);
//Activator.CreateInstance(t);
/*
Button c = (Button)b;
c.Location = new System.Drawing.Point(int.Parse(left) , int.Parse(top));
c.Text = text;
c.Name = "boton" + i.ToString();
*/
t.InvokeMember("Location", BindingFlags.SetProperty, null, b,
new object[] {new System.Drawing.Point(int.Parse(left) , int.Parse(top))});
t.InvokeMember("Text", BindingFlags.SetProperty, null, b, new object[] {text});
t.InvokeMember("Name", BindingFlags.SetProperty, null, b, new object[] {"control" + i.ToString()});
//PropertyInfo pi = t.GetProperty("Name");
//PropertyInfo pi2 = t.GetProperty("Pepe");
this.Controls.Add((Control)b);
}
}
示例12: Init
private static void Init()
{
System.Xml.XmlDocument _document = new System.Xml.XmlDocument();
_document.Load(Xy.Tools.IO.File.foundConfigurationFile("App", Xy.AppSetting.FILE_EXT));
_connections = new Dictionary<string, DataSettingItem>();
foreach (System.Xml.XmlNode _item in _document.SelectNodes("AppSetting/ConnectionStrings/Item")) {
DataSettingItem _dbi = new DataSettingItem(
_item.Attributes["Name"].Value,
_item.Attributes["ConnectionString"].Value,
_item.Attributes["Provider"].Value,
_item.Attributes["TimeOut"] == null ? 30 : Convert.ToInt32(_item.Attributes["TimeOut"].Value));
_connections.Add(_dbi.Name, _dbi);
}
}
示例13: ParseParams
public static Dictionary<string, string> ParseParams(string paramString)
{
var d = new Dictionary<string,string>();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(paramString);
var nsMgr = new System.Xml.XmlNamespaceManager(doc.NameTable);
nsMgr.AddNamespace("x", "urn:schemas-microsoft-com:xml-analysis");
foreach( System.Xml.XmlNode n in doc.SelectNodes("/x:Parameters/x:Parameter",nsMgr))
{
d.Add(n["Name"].InnerText, n["Value"].InnerText);
}
// if we did not find the proper namespace try searching for just the raw names
if (d.Count == 0)
{
foreach (System.Xml.XmlNode n in doc.SelectNodes("/Parameters/Parameter", nsMgr))
{
d.Add(n["Name"].InnerText, n["Value"].InnerText);
}
}
return d;
}
示例14: GetArrayVal
public static string[] GetArrayVal(string xml, string xpath, bool isGetXml)
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.LoadXml(xml);
System.Xml.XmlNodeList xnl = xd.SelectNodes(xpath);
List<string> list = new List<string>();
if (xnl.Count > 0)
{
foreach (System.Xml.XmlNode xn in xnl)
{
list.Add(isGetXml ? xn.InnerXml : xn.InnerText);
}
}
return list.ToArray();
}
示例15: Index
public ActionResult Index()
{
string[] colors = new string[] {
"#8D38C9",
"#00FFFF",
"#FF00FF",
"#008000",
"#FFFF00",
"#0000FF",
"#FF0000"
};
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("~/Areas/Draw_Basic/Content/Australia.xml"));
List<object> info = new List<object>();
List<AbstractSprite> sprites = new List<AbstractSprite>();
int i = 0;
foreach (System.Xml.XmlNode state in doc.SelectNodes("states/state"))
{
PathSprite sprite = new PathSprite
{
Path = state.SelectSingleNode("path").InnerText,
FillStyle = "#808080",
StrokeStyle = "#000",
LineWidth = 1,
Linejoin = StrokeLinejoin.Round
//Cursor = "pointer"
};
//sprite.Listeners.MouseOver.Handler = string.Format("onMouseOver(this, {0}, {1});", JSON.Serialize(colors[i]), i);
//sprite.Listeners.MouseOut.Handler = "onMouseOut(this);";
sprites.Add(sprite);
i++;
info.Add(new
{
state = state.SelectSingleNode("name").InnerText,
desc = state.SelectSingleNode("description").InnerText
});
}
ViewData["mapInfo"] = info;
return View(sprites);
}