本文整理汇总了C#中XmlDocument.SelectSingleNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.SelectSingleNode方法的具体用法?C# XmlDocument.SelectSingleNode怎么用?C# XmlDocument.SelectSingleNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.SelectSingleNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveStatistik
public void SaveStatistik(string statText, string name)
{
CheckFile ();
// Создаем корневой элемент
XmlDocument xmlDoc = new XmlDocument ();
if(File.Exists(filePatch))
xmlDoc.Load (filePatch);
XmlNode xRoot;
XmlNode findNode = xmlDoc.SelectSingleNode ("Stats"); // найти корневой элемент
if ( findNode == null)
xRoot = xmlDoc.CreateElement ("Stats"); // Создать корневой элемент
else
xRoot = findNode;
xmlDoc.AppendChild (xRoot);
//Временные преременные для дочерних элементов и атрибутов
XmlElement taskElement1; //Элемент 1-го уровня
findNode = xmlDoc.SelectSingleNode ("Stats/" + name);
if ( findNode == null) {
taskElement1 = xmlDoc.CreateElement (name);
taskElement1.InnerText = statText;
xRoot.AppendChild (taskElement1);
} else {
findNode.InnerText = statText;
}
/////////////////////////////////////////////////////////////
xmlDoc.Save ("Data/Save/Stats.xml");
}
示例2: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
string index = Label2.Text;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/" + "ad.xml"));
XmlNode root = xmlDoc.SelectSingleNode("ttt");
XmlNodeList xnl = xmlDoc.SelectSingleNode("ttt").ChildNodes;
for (int i = 0; i < xnl.Count; i++)
{
XmlElement xe = (XmlElement)xnl.Item(i);
if (xe.GetAttribute("index") == index)
{
xe.SetAttribute("src", TextBox1.Text);
xe.SetAttribute("href",TextBox4.Text);
xe.SetAttribute("target", TextBox5.Text);
}
}
//root.PrependChild(xe);
xmlDoc.Save(Server.MapPath("~/" + "ad.xml"));
msg("更新flash成功了");
return;
Response.Redirect("adselect.aspx");
}
示例3: GenerateAction_Click
protected void GenerateAction_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(Resources.MyResourceStrings.MyDocument);
XmlNode TextNode;
XmlNamespaceManager NsMgr = new XmlNamespaceManager(doc.NameTable);
NsMgr.AddNamespace("ns1", "uri:AspNetPro20/Chapter16/Demo1");
NsMgr.AddNamespace("w", "http://schemas.microsoft.com/office/word/2003/wordml");
TextNode = doc.SelectSingleNode("//ns1:Firstname//w:p", NsMgr);
TextNode.InnerXml = string.Format("<w:r><w:t>{0}</w:t></w:r>", TextFirstname.Text);
TextNode = doc.SelectSingleNode("//ns1:Lastname//w:p", NsMgr);
TextNode.InnerXml = string.Format("<w:r><w:t>{0}</w:t></w:r>", TextLastname.Text);
TextNode = doc.SelectSingleNode("//ns1:Age//w:p", NsMgr);
TextNode.InnerXml = string.Format("<w:r><w:t>{0}</w:t></w:r>", TextAge.Text);
// Clear the response
Response.Clear();
Response.ContentType = "application/msword";
Response.Write(doc.OuterXml);
Response.End();
}
示例4: Module_Action_Delete
private string Module_Action_Delete()
{
string tmpstr = "";
string trootstr = cls.getSafeString(encode.base64.decodeBase64(request.querystring("root")));
string tvaluestr = cls.getSafeString(encode.base64.decodeBase64(request.querystring("value")));
if (com.fileExists(Server.MapPath(trootstr)))
{
try
{
string tnode, tfield, tbase;
XmlDocument tXMLDom = new XmlDocument();
tXMLDom.Load(Server.MapPath(trootstr));
XmlNode tXmlNode = tXMLDom.SelectSingleNode("/xml/configure");
tnode = tXmlNode.ChildNodes.Item(0).InnerText;
tfield = tXmlNode.ChildNodes.Item(1).InnerText;
tbase = tXmlNode.ChildNodes.Item(2).InnerText;
XmlNode tXmlNodeDel = tXMLDom.SelectSingleNode("/xml/" + tbase + "/" + tnode + "[" + cls.getLRStr(tfield, ",", "left") + "='" + tvaluestr + "']");
if (tXmlNodeDel != null)
{
tXmlNodeDel.ParentNode.RemoveChild(tXmlNodeDel);
tXMLDom.Save(Server.MapPath(trootstr));
}
tmpstr = jt.itake("global.lng_common.delete-succeed", "lng");
}
catch
{
tmpstr = jt.itake("global.lng_common.delete-failed", "lng");
}
}
else tmpstr = jt.itake("global.lng_common.delete-failed", "lng");
tmpstr = config.ajaxPreContent + tmpstr;
return tmpstr;
}
示例5: parseProfile
protected void parseProfile(string XML)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(XML);
gold = int.Parse (xmlDoc.SelectSingleNode ("player/gold").InnerText);
cash = int.Parse (xmlDoc.SelectSingleNode ("player/cash").InnerText);
}
示例6: GetFeed
public Collection<Rss.Items> GetFeed()
{
if (String.IsNullOrEmpty(Url))
throw new ArgumentException("Bir Rss adresi belirtmelisiniz");
try
{
using (XmlReader reader = XmlReader.Create(Url))
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(reader);
}
catch
{
MessageBox.Show("Baþvurulan adreste bir söz dizimi hatasý var.\nSite yöneticilerine haber verin.");
}
ParseDocElements(xmlDoc.SelectSingleNode("//channel"), "title", ref _feedTitle);
ParseDocElements(xmlDoc.SelectSingleNode("//channel"), "description", ref _feedDescription);
ParseRssItems(xmlDoc);
return _rssItems;
}
}
catch
{
MessageBox.Show("Servis þu anda hizmet vermiyor");
return _rssItems;
}
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Session["userid"] == null)
{
this.Response.Write("<script language=\"javascript\">");
this.Response.Write("alert('您未正常登录,请登录后再使用,谢谢!')");
this.Response.Write("</script>");
this.Response.Redirect("index.htm");
}
string strcn = DataAccRes.DefaultDataConnInfo.Value;
SqlConnection CN = new SqlConnection(strcn);
XmlDocument xmldoc = new XmlDocument();
//读取用户参数
StreamReader streamreader = new StreamReader(this.Request.InputStream, Encoding.UTF8);
xmldoc.LoadXml(streamreader.ReadToEnd());
if (xmldoc == null) return;
string strcmd = xmldoc.SelectSingleNode("//all/command").InnerText;
string strdata = xmldoc.SelectSingleNode("//all/data").InnerText;
string xmlstr = "";
switch (strcmd)
{
case "pwd":
User user = new User(this.Session["userid"].ToString());
string oldpwd = basefun.valtag(strdata,"pwdold");
if (this.Session["userkey"].ToString() != oldpwd)
{
xmlstr = "<table><result>原密码不正确!</result></table>";
break;
}
string newpwd = basefun.valtag(strdata, "pwdnew");
bool bModify = user.ModifyPassword(oldpwd, newpwd);
if (!bModify)
{
xmlstr = "<table><result>修改失败!</result></table>";
}
else
{
xmlstr = "<table><result>修改成功!</result></table>";
}
break;
case "querydb":
string systemdb = DataAccRes.AppSettings("SystemDB");
xmlstr = "<table><svr>" + CN.DataSource + "</svr><userdb>" + CN.Database + "</userdb><sysdb>" + systemdb + "</sysdb></table>";
break;
case "updatedb":
WriteWebConfig(strdata);
xmlstr = "<table><result>修改成功!</result></table>";
break;
}
Response.ContentType = "text/xml";
Response.Expires = -1;
Response.Clear();
Response.Write("<?xml version='1.0' encoding='GB2312'?>");
Response.Write(xmlstr);
//Response.End();
}
示例8: QueryCustInfo
// 客户信息查询接口 lihongtu
public static Int32 QueryCustInfo(String ProductNo, out CustInfo custinfo, out String ErrMsg)
{
Int32 Result = ErrorDefinition.CIP_IError_Result_UnknowError_Code;
ErrMsg = ErrorDefinition.CIP_IError_Result_UnknowError_Msg;
String TransactionID = CreateTransactionID();
StringBuilder requestXml = new StringBuilder();
String responseXml = String.Empty;
custinfo = new CustInfo();
try
{
#region 拼接请求xml字符串
//100101 客户查询
requestXml.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
requestXml.Append("<PayPlatRequestParameter>");
requestXml.Append("<CTRL-INFO WEBSVRNAME=\"客户查询\" WEBSVRCODE=\"100101\" APPFROM=\"100101|310000-TEST1-127.0.0.1|1.0|127.0.0.1\" KEEP=\"" + TransactionID + "\" />");
requestXml.Append("<PARAMETERS>");
//添加参数
requestXml.AppendFormat("<PRODUCTNO>{0}</PRODUCTNO>", "yy" + ProductNo);
requestXml.AppendFormat("<ACCEPTORGCODE>{0}</ACCEPTORGCODE>", BesttoneAccountConstDefinition.DefaultInstance.ACCEPTORGCODE); //002310000000000
requestXml.AppendFormat("<ACCEPTSEQNO>{0}</ACCEPTSEQNO>", TransactionID);
requestXml.AppendFormat("<INPUTTIME>{0}</INPUTTIME>", DateTime.Now.ToString("yyyyMMddHHmmss"));
requestXml.Append("</PARAMETERS>");
requestXml.Append("</PayPlatRequestParameter>");
#endregion
//请求接口
responseXml = serviceProxy.dispatchCommand("100101|310000-TEST1-127.0.0.1|1.0|127.0.0.1", requestXml.ToString());
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(responseXml);
String responseCode = xmlDoc.SelectSingleNode("/PayPlatResponseParameter/RESPONSECODE").InnerText;
ErrMsg = xmlDoc.SelectSingleNode("/PayPlatResponseParameter/RESPONSECONTENT").InnerText;
if (responseCode == "000000")
{
XmlNode dataNode = xmlDoc.SelectNodes("/PayPlatResponseParameter/RESULTDATESET/DATAS")[0];
custinfo.CustomerNo = dataNode.Attributes["CUSTOMER_NO"].Value;
custinfo.ProductNo = dataNode.Attributes["PRODUCT_NO"].Value;
custinfo.CustomerName = dataNode.Attributes["CUSTOMER_NAME"].Value;
custinfo.IdType = dataNode.Attributes["ID_TYPE"].Value;
custinfo.IdNo = dataNode.Attributes["ID_NO"].Value;
Result = 0;
ErrMsg = String.Empty;
}
}
catch (System.Exception ex)
{
}
return Result;
}
示例9: Page_Load
protected void Page_Load (object sender, EventArgs e)
{
if (Request.QueryString["ticket"] != null && hTicket.Value == "")
{
//this is the callback
this.hTicket.Value = Request.QueryString["ticket"].ToString();
LoginPanel.Visible = false;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://pirateweb.net/Pages/Security/ValidateTicket.aspx?ticket=" + Request.QueryString["ticket"].ToString());
//HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:2900/Pages/Security/ValidateTicket.aspx?ticket=" + Request.QueryString["ticket"].ToString());
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tmp = reader.ReadToEnd();
response.Close();
Response.ContentType = "text/xml";
Response.Clear();
Response.Write(tmp);
Response.End();
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(tmp);
ResultPanel.Visible = true;
resultdiv.InnerHtml = "";
if (xdoc.SelectSingleNode("//USER") != null)
{
resultdiv.InnerHtml += xdoc.SelectSingleNode("//USER/ID").InnerText;
resultdiv.InnerHtml += "<BR>";
resultdiv.InnerHtml += xdoc.SelectSingleNode("//USER/NAME").InnerText;
resultdiv.InnerHtml += "<BR>";
resultdiv.InnerHtml += xdoc.SelectSingleNode("//USER/GEOGRAPHIESFORPERSON/GEOGRAPHY").Attributes["name"];
resultdiv.InnerHtml += "<BR>";
}
else
{
resultdiv.InnerHtml=xdoc.InnerText;
}
}
else if (this.hTicket.Value != "")
{
//the callback has been done we are running normally logged in
}
else
{
// prepare for login
LoginPanel.Visible = true;
}
}
示例10: NewGame
//.Load("Assets/Scripts/SaveGame.xml")
////---For encrypted one---
////Read in SaveGame.xml
//XmlDocument SaveGameDoc = new XmlDocument();
//SaveGameDoc.LoadXml(DoSaveGame.FetchSaveData());
////---For encrypted one---
////Save XML
//DoSaveGame.UpdateSaveData(SaveGameDoc);
//.LoadXml(Resources.Load("Defult Save/DefultSaveGame.xml").ToString()
//.LoadXml(Resources.Load("CutScenes/CutSceneEvents.xml").ToString()
//.LoadXml(Resources.Load("ItemFile/Items.xml").ToString()
public static void NewGame()
{
//Read in DefultSaveGame.xml
XmlDocument DefultSaveGameDoc = new XmlDocument();
DefultSaveGameDoc.LoadXml(Resources.Load("Defult Save/DefultSaveGame").ToString());
//Getting GameVersion and inputting it into SaveGameData
StreamReader SR = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Delirium/Version.txt");
DefultSaveGameDoc.SelectSingleNode("SaveData/Settings/GameVersion").InnerText = SR.ReadLine();
DefultSaveGameDoc.SelectSingleNode("SaveData/Settings/DateTimeStarted").InnerText = System.DateTime.Now.ToString();
SR.Close();
//Update/Save Data
UpdateSaveData(DefultSaveGameDoc);
}
示例11: getCartelCine
public Cartelera getCartelCine()
{
doc = new XmlDocument();
try
{
doc.Load("http://www.cinepolis.com.mx/iphone/xml-iphone.aspx?query=cartelera&ci=" + cartel.CiudadID);
}
catch (Exception e) { return null; }
try
{
complejoInfo = doc.SelectSingleNode("//Cartelera//Complejo[@Complejoid='" + cartel.ComplejoID + "']");
cartel.Complejo = complejoInfo.Attributes.GetNamedItem("Nombre").Value;
cartel.Latitud = complejoInfo.ChildNodes[1].InnerText.Trim();
cartel.Longitud = complejoInfo.ChildNodes[2].InnerText.Trim();
Complejos_peli = doc.SelectNodes("//Cartelera//Complejo[@Complejoid='" + cartel.ComplejoID + "']/Pelicula");
foreach (XmlNode complejo_peli in Complejos_peli)
{
peli = new Pelicula();
string Horario_Peli = "";
peli.PeliculaID = complejo_peli.FirstChild.InnerText;
Complejos_hora = doc.SelectNodes("//Cartelera//Complejo/Pelicula[Peliculaid='" + peli.PeliculaID + "']/Horarios/Horario");
foreach (XmlNode horario in Complejos_hora)
{
Horario_Peli += horario.InnerText + " - ";
}
peliculaInfo = doc.SelectSingleNode("//Peliculas//Pelicula[@Peliculaid='" + peli.PeliculaID + "']");
peli.Nombre = peliculaInfo.Attributes.GetNamedItem("Nombre").Value;
peli.Clasificacion = peliculaInfo.ChildNodes[1].InnerText;
peli.Calificacion = peliculaInfo.ChildNodes[4].InnerText;
peli.Descripcion = peliculaInfo.ChildNodes[6].InnerText;
peli.Director = peliculaInfo.ChildNodes[7].InnerText;
peli.Actor = peliculaInfo.ChildNodes[8].InnerText;
peli.Duracion = peliculaInfo.ChildNodes[16].InnerText;
peli.Trailer = peliculaInfo.ChildNodes[19].InnerText;
peli.Horarios = Horario_Peli;
cartel.Peliculas.Add(peli);
}
}
catch (Exception e) { return null;}
return cartel;
}
示例12: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string id = Request.QueryString["id"], xpathExpr;
int counter = 0;
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("../Xml/Playlists.xml"));
if (id != "0")
{
xpathExpr = "/playlists/playlist[id='" + id + "']";
XmlNode node_id = doc.SelectSingleNode(xpathExpr);
Response.Write("{ \"id\": \"" + node_id.ChildNodes[0].InnerText.Trim() + "\", \"title\": \"" + node_id.ChildNodes[1].InnerText.Trim() + "\", \"songs\": ");
Response.Write("[");
foreach (XmlNode node in node_id.ChildNodes[2])
{
Response.Write("{ \"id\": \"" + node.ChildNodes[0].InnerText.Trim() + "\" }");
counter++;
if (counter < node_id.ChildNodes[2].ChildNodes.Count) Response.Write(", ");
}
Response.Write("] }");
}
}
示例13: LoadFloatArrFromXML
public float[,] LoadFloatArrFromXML(string fileName, int col, int row)
{
float[, ] resultArr = new float[col, row];
string xmlStr = Resources.Load ("Data/" + fileName).ToString ();
XmlDocument xml = new XmlDocument ();
xml.LoadXml (xmlStr);
XmlNodeList xmlNodeList = xml.SelectSingleNode ("data").ChildNodes;
int i = 0, j;
foreach (XmlElement xmlE in xmlNodeList)
{
j = 0;
foreach (XmlElement xmlEE in xmlE)
{
resultArr[i, j] = float.Parse (xmlEE.InnerText);
j++;
}
i++;
}
return resultArr;
}
示例14: Load
public void Load()
{
xmldoc = new XmlDocument();
xmldoc.Load("Config.xml");
root = xmldoc.SelectSingleNode("XML");
}
示例15: BitlyShortLink
public static string BitlyShortLink(string longLink)
{
string bitlyResponse = ExecuteGetCommand(string.Format(bitlyUrl, longLink));
XmlDocument doc = new XmlDocument();
doc.LoadXml(bitlyResponse);
return doc.SelectSingleNode("//url").InnerText;
}