<1>
<a>3</a>
<f>g</f>
<r>f</r>
<k>l</k>
</1>
<2>
<a>3t</a>
<f>gg</f>
<r>fe</r>
<k>ls</k>
</2>
<3>
<a>3v</a>
<f>ge</f>
<r>fdd</r>
<k>lhht</k>
</3>
<4>
<a>123</a>
<f>dd</f>
<r>ff</r>
<k>lb</k>
</4>我想当我查询进来的ID=?的时候进行查询!
之后读取这个接点下的所有的东西!
怎么办?在线等急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<a>3</a>
<f>g</f>
<r>f</r>
<k>l</k>
</1>
<2>
<a>3t</a>
<f>gg</f>
<r>fe</r>
<k>ls</k>
</2>
<3>
<a>3v</a>
<f>ge</f>
<r>fdd</r>
<k>lhht</k>
</3>
<4>
<a>123</a>
<f>dd</f>
<r>ff</r>
<k>lb</k>
</4>我想当我查询进来的ID=?的时候进行查询!
之后读取这个接点下的所有的东西!
怎么办?在线等急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
解决方案 »
- 远程服务器返回了意外响应: (400) Bad Request。
- 关于opendialog控件
- listView得到选定项怎么会有问题?
- enterprise library 能不能操作oracle
- 100分求Windows Live Mail 和 Live Messager邀请.
- 如何开始一个winForm和webUI共用一个业务逻辑的项目?
- 15.625毫秒(1/64秒)这个特殊的数值含义
- 菜鸟提问:如何取得页面的所有链接(正则表达式)
- 请问:那里有比较好的c#电子图书下载,最好是介绍.net开发环境的
- 关于自动排课算法!高分!!!
- 用循环在一指定文件夹中,生成str[i].txt记事本文件,并对str[i].txt写入text!
- 菜鸟求picture box一个问题,解决马上给分
比如
public void A(int 1)
{
XmlDocument xd = new XmlDocument();
xd.LoadXml("");
XmlNode no = xd.SelectNodes();
}急等!谢了!
Labe2.text = <f></f>
Labe3.text = <r></r>
Labe3.text = <k></k>
{
XmlDocument xmlDoc = new XmlDocument();
string strPath = "root/itemData/cell"; //查询路径
XmlNodeList nodeList = null;
string strItem = ""; //item值
string strKey = ""; //key值
string strValue = ""; //value值
try
{
xmlDoc.Load("e:\\新建 文本文档 (2).xml"); //获取所有的itemData项
nodeList = xmlDoc.SelectNodes(strPath);
//遍历所有节点
foreach (XmlNode node in nodeList)
{
strItem = node.Attributes["item"].InnerText;
//遍历所有字节点
foreach (XmlNode subNode in node.ChildNodes)
{
strKey=subNode.Attributes["key"].InnerText;
strValue = subNode.Attributes["value"].InnerText; //strItem,strKey,strValue值都获取了,剩下就是对数据库操作,我就不再多说
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
using System.CodeDom.Compiler;
using System.Reflection;
using System.Text;
using Microsoft.CSharp;
using System.Collections.Generic;
using System.Xml;public class MyClass
{ public static void Main()
{
try
{
string xml = @"
<root>
<node id=""1"">
<a>3</a>
<f>g</f>
<r>f</r>
<k>l</k>
</node>
<node id=""2"">
<a>3t</a>
<f>gg</f>
<r>fe</r>
<k>ls</k>
</node>
<node id=""3""> <a>3v</a>
<f>ge</f>
<r>fdd</r>
<k>lhht</k>
</node>
<node id=""4""> <a>123</a>
<f>dd</f>
<r>ff</r>
<k>lb</k>
</node>
</root>
"; XmlDocument xd = new XmlDocument();
xd.LoadXml(xml);
XmlElement xe = xd.DocumentElement;
int id=2;
string xpath = String.Format(@"//node[@id=""{0}""]",id);
XmlNode xn = xd.SelectSingleNode(xpath);
if (xn != null) {
foreach (XmlNode x in xn.ChildNodes) {
Console.WriteLine("name:{0}\tvalue:{1}", x.Name, x.InnerText);
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Console.WriteLine("END");
Console.Read();
}
}
}=====运行结果
name:a value:3t
name:f value:gg
name:r value:fe
name:k value:ls
END
xmlDoc.Load(Server.MapPath("your.xml"));
XmlNodeList nodeList=xmlDoc.SelectNodes(节点路径);
Labe1.text =nodeList[0].InnerText;
Labe2.text =nodeList[1].InnerText;
Labe3.text =nodeList[2].InnerText;
xmlDoc.Load(Server.MapPath("your.xml"));
XmlNode xmlnode = doc.SelectSingleNode(//跟节点[@menuName="1");
if (xmlnode != null)
{
Labe1.text=xmlnode.Attribut.["menuName"].Value.ToString();
Labe2.text=xmlnode.Attribut.["menuName"].Value.ToString();
Labe3.text=xmlnode.Attribut.["menuName"].Value.ToString();
}
/// <summary>
/// Config 的摘要说明。
/// </summary>
public class Config
{
private String msFileName = null;
/// <summary>
/// 设置或获取文件名
/// </summary>
public String ConfigFile
{
get
{
return this.msFileName;
}
set
{
if(System.IO.File.Exists(value.Trim()))
{
this.msFileName = value.Trim();
}
}
} private Stream msFile=null;
/// <summary>
/// 设置文件流
/// </summary>
///
public Stream setFileStream
{
set
{
this.msFile=value;
}
} public Config()
{
this.msFileName = String.Empty;
} public Config(String ConfigFile)
{
this.ConfigFile = ConfigFile.Trim();
} private System.Xml.XmlDocument xmlDoc=new System.Xml.XmlDocument();
/// <summary>
/// 打开xml文档
/// </summary>
/// <param name="ContentName"></param>
/// <param name="ContentValue"></param>
/// <returns></returns>
///
public void OpenXml()
{
try
{
if(!System.IO.File.Exists(this.msFileName))
{
xmlDoc.Load(this.msFile);
}
else
{
xmlDoc.Load(this.msFileName);
}
}
catch(XmlException ex)
{
System.Console.WriteLine(ex.Message);
}
} public bool ReadConfig(String ContentName, out String ContentValue)
{
bool bFlag = false;
ContentValue = String.Empty;
try
{
System.Xml.XmlNode xmlNode = xmlDoc.SelectSingleNode(ContentName);
string xx=xmlNode.InnerText;
ContentValue=xx;
//ContentValue = xmlNode.InnerText;
bFlag = true;
}
catch (XmlException xmle)
{
System.Console.WriteLine(xmle.Message);
}
return bFlag;
} public bool ReadConfig(String ContentName, String PropertyName, out String PropertyValue)
{
bool bFlag = false; PropertyValue = String.Empty;
try
{
XmlNode xmlNode = xmlDoc.SelectSingleNode(ContentName); XmlAttributeCollection xmlAttr = xmlNode.Attributes; for(int i=0; i<xmlAttr.Count; ++i)
{
if (xmlAttr.Item(i).Name == PropertyName)
{
PropertyValue = xmlAttr.Item(i).Value;
bFlag = true;
break;
}
}
}
catch (XmlException xmle)
{
System.Console.WriteLine(xmle.Message);
} return bFlag;
} public bool WriteConfig(String ContentName, String ContentValue)
{
bool bFlag = false; if (!System.IO.File.Exists(this.msFileName))
{
return bFlag;
} try
{
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(this.msFileName);
System.Xml.XmlNode xmlNode = xmlDoc.SelectSingleNode(ContentName);
xmlNode.InnerText = ContentValue; xmlDoc.Save(this.msFileName); bFlag = true;
}
catch (XmlException xmle)
{
System.Console.WriteLine(xmle.Message);
} return bFlag;
} public bool WriteConfig(String ContentName, String PropertyName, String PropertyValue)
{
bool bFlag = false; if (!System.IO.File.Exists(this.msFileName))
{
return bFlag;
} try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(this.msFileName); XmlNode xmlNode = xmlDoc.SelectSingleNode(ContentName); XmlAttributeCollection xmlAttr = xmlNode.Attributes; for (int i = 0; i < xmlAttr.Count; ++i)
{
if (xmlAttr.Item(i).Name == PropertyName)
{
xmlAttr.Item(i).Value = PropertyValue;
bFlag = true;
break;
}
} xmlDoc.Save(this.msFileName); bFlag = true;
}
catch (XmlException xmle)
{
System.Console.WriteLine(xmle.Message);
} return bFlag;
}
}
#endregion