- <root>
<quantity>2</quantity>
- <statelist>
<state id="3" name="测试者7" id_no="3625241987125317" telphone="12121111111" areaname="厦门市" orgname="厦门市翔安区内厝卫生院" diagnosis="" catalogName="高血压" diagnosistime="2011/11/8 0:00:00" sex="1">3</state>
<state id="1" name="易诺欣" id_no="35020319570503110X" telphone="1595959295209" areaname="福州市" orgname="鼓楼区阔埕街卫生服务中心" diagnosis="" catalogName="高血压" diagnosistime="2011/11/7 0:00:00" sex="2">3</state>
</statelist>
</root>
string strParm ="1,3";
string strXml="上面的xml"怎么把1,3当成是state 的id 传入得到xml的格式为(比如传入的是3)- <statelist>
<state id="3" name="测试者7" id_no="3625241987125317" telphone="12121111111" areaname="厦门市" orgname="厦门市翔安区内厝卫生院" diagnosis="" catalogName="高血压" diagnosistime="2011/11/8 0:00:00" sex="1">3</state>
</statelist>
<quantity>2</quantity>
- <statelist>
<state id="3" name="测试者7" id_no="3625241987125317" telphone="12121111111" areaname="厦门市" orgname="厦门市翔安区内厝卫生院" diagnosis="" catalogName="高血压" diagnosistime="2011/11/8 0:00:00" sex="1">3</state>
<state id="1" name="易诺欣" id_no="35020319570503110X" telphone="1595959295209" areaname="福州市" orgname="鼓楼区阔埕街卫生服务中心" diagnosis="" catalogName="高血压" diagnosistime="2011/11/7 0:00:00" sex="2">3</state>
</statelist>
</root>
string strParm ="1,3";
string strXml="上面的xml"怎么把1,3当成是state 的id 传入得到xml的格式为(比如传入的是3)- <statelist>
<state id="3" name="测试者7" id_no="3625241987125317" telphone="12121111111" areaname="厦门市" orgname="厦门市翔安区内厝卫生院" diagnosis="" catalogName="高血压" diagnosistime="2011/11/8 0:00:00" sex="1">3</state>
</statelist>
解决方案 »
- 一个关于HTML的问题
- 动态添加DropDownList时值的判断
- roles不能写入forms验证里的验证票...
- 点击DataGrid中的ImageButton按钮弹出窗口问题
- iframe 面页用JS传值问题
- 急!!!关于执行带参数的SQL语句的错误。
- how to declare global conditional compilation symbol in vs.net 2008 web.config ?
- 可以同时用一个应用程序和一个WEB应用程序(ASP.NET)访问访问(ACCESS)数据库吗?
- 微软官方ASP.NET.2.0快速入门 数据绑定那个教程的问题
- 怎么没有人帮我呢
- 关于不同语言的页面跳转
- mvc
xmlDoc.load("F:\\1.xml");
var node=xmlDoc.SelectSingleNode("//statelist/state[id=\"3\"]");
return node.OuterXml;
参考: http://www.w3school.com.cn/xpath/
//获取Xml文件
XElement xl=XElement.Load(Server.MapPath(Constant.MenuFile));
//获得指定的子节点
IEnumerable<XElement> node = from a in xl.Elements()
where a.Attribute("id").Value == "7"
select a;
//遍历循环指定的子节点
foreach (XElement xx in node.Elements())
{
int lastId=Convert.ToInt32(xx.Elements().Last().Attribute("id").Value)+1;
if (xx.Attribute("id").Value == "71")
{
//创建节点
XElement xtt=new XElement ("menu",
new XAttribute("id",lastId),
new XAttribute("pid","71"),
new XAttribute("name",this.txtSceneryName.Text),
new XAttribute("subject","#"),
new XAttribute("url","../Scenery/SceneryPicture.aspx")
);
//添加节点
xx.Add(xtt);
//保存XML文件
xl.Save(Server.MapPath(Constant.MenuFile));
}
}
参考!