日期:2014-05-20 浏览次数:20817 次
XMLDocument doc = new XMLDocument() doc.LoadXML(@"<?xml version="1.0" encoding="utf-8" ?> <customerInfo> <NO1> <name>testusd</customerAccount> //你的xml不合法 customerAccount没有开始标记 <age>12</customerName> <address>testusd</address> </NO1> <NO2> <name>test</customerAccount> <age>19</customerName> <address>test</address> </NO2> </customerInfo>"); txtName.Text=doc.SelectSingleNode("//NO1/name").InnerText; txtAge.Text=doc.SelectSingleNode("//NO1/age").InnerText; txtAddress.Text=doc.SelectSingleNode("//NO1/address").InnerText;
------解决方案--------------------
XmlDocument doc=new XmlDocument(); doc.Load(Server.MapPath(ConfigurationSettings.AppSettings["xxx"])); //Load XmlNode root=doc.DocumentElement;//根节点 XmlNode opReq=root.SelectSingleNode("xxx"); XmlNode Param=opReq.SelectSingleNode("xxx"); string strName=Param.SelectSingleNode("xxx").value;
------解决方案--------------------
用 XmlDocument
------解决方案--------------------
通用XML读取器 收藏
view plaincopy to clipboardprint?
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//声明XmlReader对象,因为从数据读的时候返回的是这个对象,方便两种方式读取