本文整理汇总了C#中System.Xml.XmlDocument.SelectSingleNode方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.SelectSingleNode方法的具体用法?C# System.Xml.XmlDocument.SelectSingleNode怎么用?C# System.Xml.XmlDocument.SelectSingleNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.SelectSingleNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: toImgur
public static ImageInfo toImgur(Bitmap bmp)
{
ImageConverter convert = new ImageConverter();
byte[] toSend = (byte[])convert.ConvertTo(bmp, typeof(byte[]));
using (WebClient wc = new WebClient())
{
NameValueCollection nvc = new NameValueCollection
{
{ "image", Convert.ToBase64String(toSend) }
};
wc.Headers.Add("Authorization", Imgur.getAuth());
ImageInfo info = new ImageInfo();
try
{
byte[] response = wc.UploadValues("https://api.imgur.com/3/upload.xml", nvc);
string res = System.Text.Encoding.Default.GetString(response);
var xmlDoc = new System.Xml.XmlDocument();
xmlDoc.LoadXml(res);
info.link = new Uri(xmlDoc.SelectSingleNode("data/link").InnerText);
info.deletehash = xmlDoc.SelectSingleNode("data/deletehash").InnerText;
info.id = xmlDoc.SelectSingleNode("data/id").InnerText;
info.success = true;
}
catch (Exception e)
{
info.success = false;
info.ex = e;
}
return info;
}
}
示例2: SetNode
private static void SetNode(string cpath)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(cpath);
Console.WriteLine("Adding to machine.config path: {0}", cpath);
foreach (DataProvider dp in dataproviders)
{
System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
if (node == null)
{
System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
node = doc.CreateElement("add");
System.Xml.XmlAttribute at = doc.CreateAttribute("name");
node.Attributes.Append(at);
at = doc.CreateAttribute("invariant");
node.Attributes.Append(at);
at = doc.CreateAttribute("description");
node.Attributes.Append(at);
at = doc.CreateAttribute("type");
node.Attributes.Append(at);
root.AppendChild(node);
}
node.Attributes["name"].Value = dp.name;
node.Attributes["invariant"].Value = dp.invariant;
node.Attributes["description"].Value = dp.description;
node.Attributes["type"].Value = dp.type;
Console.WriteLine("Added Data Provider node in machine.config.");
}
doc.Save(cpath);
Console.WriteLine("machine.config saved: {0}", cpath);
}
示例3: reload_Click
private void reload_Click(object sender, EventArgs e)
{
String firstNum, lastNum;
// Gets the first 4 and last 4 numbers from the Selectionbox, and saves them to a variable
firstNum = resolutionSelect.Text.Substring(0, 4);
lastNum = resolutionSelect.Text.Substring(Math.Max(0, resolutionSelect.Text.Length - 4));
// Removes any spaces from the above strings.
firstNum = firstNum.Replace(" ", "");
lastNum = lastNum.Replace(" ", "");
// Loads the Application Settings XML file
System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");
// Sets the XML attributes to the current values of the editor
appConfigXML.SelectSingleNode("//ScreenTitle").InnerText = windowTitleBox.Text;
appConfigXML.SelectSingleNode("//FullScreen").InnerText = isFullScreen.Text;
appConfigXML.SelectSingleNode("//ScreenWidth").InnerText = Convert.ToString(firstNum);
appConfigXML.SelectSingleNode("//ScreenHeight").InnerText = Convert.ToString(lastNum);
// Saves the Application Settings XML file
appConfigXML.Save(Game._path + "\\Content\\ApplicationSettings.xml");
serConfigXML.Save(Game._path + "\\Content\\ServiceSettings.xml");
MessageBox.Show("Reload Application for changes to take effect");
System.Diagnostics.Process.Start(Game._path + @"\\Devoxelation.exe");
Application.Exit();
}
示例4: GetSmsCount
/// <summary>
/// ��ȡ�������
/// </summary>
/// <param name="SiteID"></param>
/// <returns></returns>
public static string GetSmsCount(string SiteID)
{
string UserName = "";
string Password = "";
string mToUrl = ""; //�������õ�url
string mRtv = ""; //���õķ����ַ���
string strSMSConfigPath = System.Web.HttpContext.Current.Server.MapPath("/Admin/Config/" + SiteID + "/SiteConfig.config");
if (System.IO.File.Exists(strSMSConfigPath))
{
System.Xml.XmlDocument XDTop = new System.Xml.XmlDocument();
XDTop.Load(strSMSConfigPath);
UserName = XDTop.SelectSingleNode("DB/SMSConfig/SMSUserName").InnerText;
Password = XDTop.SelectSingleNode("DB/SMSConfig/SMSPassword").InnerText;
}
// �û�����
mToUrl = "http://www.139000.com/send/getfee.asp?name=" + UserName + "&pwd=" + Password;
System.Net.HttpWebResponse rs = (System.Net.HttpWebResponse)System.Net.HttpWebRequest.Create(mToUrl).GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(rs.GetResponseStream(), System.Text.Encoding.Default);
mRtv = sr.ReadToEnd();
string[] arr = mRtv.Split(new char[] { '=', '&' });
return arr[1];
}
示例5: BG
public BG(string conffile)
: this()
{
System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
xmld.Load(conffile);
this.prefix = xmld.SelectSingleNode("/root/instance/prefix").Attributes["val"].Value.ToString();
this.rootDir = xmld.SelectSingleNode("/root/instance/rootDir").Attributes["val"].Value.ToString();
Path.rootDir = this.rootDir;
}
示例6: GetCoordinates
private static double[] GetCoordinates(string location)
{
double[] result = new double[2];
string url = "http://where.yahooapis.com/geocode?q=" + location + "&appid=4m2kmJ3V34Gpe6hGVj8ORcMio3s44DgMDmyS8nKHNnf6PlZwjMcoluUBzwAVXGDG";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(url);
result[0] = Convert.ToDouble(doc.SelectSingleNode("/ResultSet/Result/latitude").InnerText);
result[1] = Convert.ToDouble(doc.SelectSingleNode("/ResultSet/Result/longitude").InnerText);
return result;
}
示例7: Process
public String Process(String ReqXml)
{
String ResXml = string.Empty;
string ReqCode = string.Empty;
try
{
com.individual.helper.LogNet4.WriteMsg(ReqXml);
System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
xmldoc.LoadXml(ReqXml);
//待验证数据
string MsgData = xmldoc.SelectSingleNode("JTW91G/MsgData").OuterXml;
//数字签名
string Signature = xmldoc.SelectSingleNode("JTW91G/SignData/Signature").InnerText;
//RSA公钥
string RsaPubKey = xmldoc.SelectSingleNode("JTW91G/SignData/RsaPubKey").InnerText;
//请求指令
ReqCode = xmldoc.SelectSingleNode("JTW91G/MsgData/ReqHeader/ReqCode").InnerText;
if (com.individual.helper.RsaSha1Helper.verify(MsgData, RsaPubKey, Signature))
{ //系统类型
string OsType = xmldoc.SelectSingleNode("JTW91G/MsgData/ReqHeader/OsType").InnerText;
if (string.IsNullOrEmpty(OsType) || ("0" != OsType && "1" != OsType && "2" != OsType))
{
return GssResXml.GetResXml(ReqCode, ResCode.UL037, ResCode.UL037Desc, string.Format("<DataBody></DataBody>"));
}
//反射出具体的实现类
Type t = Type.GetType("JtwPhone.Code." + ReqCode);
//获取方法
System.Reflection.MethodInfo minfo = t.GetMethod("AnalysisXml");
//执行方法
ResXml = minfo.Invoke(System.Activator.CreateInstance(t), new Object[] { ReqXml }).ToString();
}
else //验证签名失败
{
ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL006, ResCode.UL006Desc, string.Format("<DataBody></DataBody>"));
}
}
catch (Exception ex)
{
com.individual.helper.LogNet4.WriteErr(ex);
//业务处理失败
ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL005, ResCode.UL005Desc, string.Format("<DataBody></DataBody>"));
}
return ResXml;
}
示例8: SettingsEditor_Load
private void SettingsEditor_Load(object sender, EventArgs e)
{
// Loads the Application Settings XML file
System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");
// First Tab (Application Settings)
windowTitleBox.Text = appConfigXML.SelectSingleNode("//ScreenTitle").InnerText;
resolutionSelect.Text = appConfigXML.SelectSingleNode("//ScreenWidth").InnerText + " x " + appConfigXML.SelectSingleNode("//ScreenHeight").InnerText;
isFullScreen.Text = Convert.ToString(appConfigXML.SelectSingleNode("//FullScreen").InnerText);
}
示例9: GeocodeLocation
public Location GeocodeLocation(string address)
{
var url = "http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=" + System.Web.HttpUtility.UrlEncode(address);
var xmlString = _client.DownloadString(url);
var xmlDoc = new System.Xml.XmlDocument();
xmlDoc.LoadXml(xmlString);
var loc = new Location();
loc.Latitude = Double.Parse(xmlDoc.SelectSingleNode("//geometry/location/lat").InnerText, NumberFormatInfo.InvariantInfo);
loc.Longitude = double.Parse(xmlDoc.SelectSingleNode("//geometry/location/lng").InnerText, NumberFormatInfo.InvariantInfo);
return loc;
}
示例10: Main
static void Main()
{
var xmlSearch = new System.Xml.XmlDocument();
//select one of the above Query, Query1
xmlSearch.Load(Query1);
var query = xmlSearch.SelectSingleNode("/query");
var author = query[Author].GetText();
var title = query[Title].GetText();
var isbn = query[ISBN].GetText();
var dbContext = new BookstoreDbContext();
var queryLogEntry = new SearchLogEntry
{
Date = DateTime.Now,
QueryXml = query.OuterXml
};
var foundBooks = GenerateQuery(author, title, isbn, dbContext);
dbContext.SearchLog.Add(queryLogEntry);
dbContext.SaveChanges();
PrintResult(foundBooks);
}
示例11: GetConfigurationFromEmbeddedFile
public static EmbeddedConfiguration GetConfigurationFromEmbeddedFile(string logicalConnectionName)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
using (System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ITPCfSQL.Azure.CLR.Configuration.Connections.xml"))
{
doc.Load(s);
}
string query = "ConnectionList/Connection[LogicalName='" + logicalConnectionName + "']";
//Microsoft.SqlServer.Server.SqlContext.Pipe.Send(query);
System.Xml.XmlNode node = doc.SelectSingleNode(query);
if (node == null)
throw new ArgumentException("Cannot find \"" + logicalConnectionName + "\" logical connection. Are you sure you spelled it right?");
try
{
return new EmbeddedConfiguration()
{
LogicalName = node.SelectSingleNode("LogicalName").InnerText,
AccountName = node.SelectSingleNode("AccountName").InnerText,
SharedKey = node.SelectSingleNode("SharedKey").InnerText,
UseHTTPS = bool.Parse(node.SelectSingleNode("UseHTTPS").InnerText)
};
}
catch (Exception exce)
{
throw new ArgumentException("There is an error in the configuration file. Some node is missing.", exce);
}
}
示例12: 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;
}
示例13: coverfromxml
public int coverfromxml(MemoryStream xmlStream)
{
int answer = 0;
try
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
xmlStream.Position = 0;
doc.Load(xmlStream);
System.Xml.XmlNode nderoot = doc.SelectSingleNode("/ComicInfo/Pages");
if (nderoot != null)
{
if (nderoot.ChildNodes.Count > 1)
{ answer = Convert.ToInt16(nderoot.FirstChild.Attributes.GetNamedItem("Image").Value); }
answer = MultipleCovers(answer, nderoot);
}
else
{
answer = -1;
}
}
catch (Exception ex)
{
Log.Instance.Write("XML Error! ", ex);
answer = -1;
}
return answer;
}
示例14: TestForAdminPackageOfWebDashboardIsEmpty
public void TestForAdminPackageOfWebDashboardIsEmpty()
{
#if BUILD
string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\Project\Webdashboard\dashboard.config");
#else
string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\..\Webdashboard\dashboard.config");
#endif
Assert.IsTrue(System.IO.File.Exists(configFile), "Dashboard.config not found at {0}", configFile);
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(configFile);
var adminPluginNode = xdoc.SelectSingleNode("/dashboard/plugins/farmPlugins/administrationPlugin");
Assert.IsNotNull(adminPluginNode, "Admin package configuration not found in dashboard.config at {0}", configFile);
var pwd = adminPluginNode.Attributes["password"];
Assert.IsNotNull(pwd, "password attribute not defined in admin packackage in dashboard.config at {0}", configFile);
Assert.AreEqual("", pwd.Value, "Password must be empty string, to force users to enter one. No default passwords allowed in distribution");
}
示例15: btnPublishFolder_Click
private void btnPublishFolder_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(txtFolderPath.Text))
{
//To Publish Folder, add Data to XML
System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
// Load XML
objXmlDocument.Load(@".\Data\PublishedFolders.xml");
System.Xml.XmlNode objXmlNode = objXmlDocument.CreateNode(System.Xml.XmlNodeType.Element,"Folder", "Folder");
// Attribute Name
System.Xml.XmlAttribute objXmlAttribute = objXmlDocument.CreateAttribute("Name");
objXmlAttribute.Value = "Carpeta";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Status
objXmlAttribute = objXmlDocument.CreateAttribute("Status");
objXmlAttribute.Value = "Enabled";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Path
objXmlAttribute = objXmlDocument.CreateAttribute("Path");
objXmlAttribute.Value = txtFolderPath.Text;
objXmlNode.Attributes.Append(objXmlAttribute);
// Add Node
objXmlDocument.SelectSingleNode("/PublishedFolders").AppendChild(objXmlNode);
// Update File
objXmlDocument.Save(@".\Data\PublishedFolders.xml");
// Refresh List
LoadFolders();
}
}