我想阅读以下 xml 并在组合框中填充知识标签,在文本框中填充itemname标记,以及在组合框中填充其余部分。任何代码示例都会非常有帮助。
<?xml version="1.0" encoding="UTF-8"?>
<swobs>
<item>
<knowledge>1</knowledge>
<knowledge>2</knowledge>
<knowledge>3</knowledge>
<knowledge>4</knowledge>
<itemname>INS Gator Operator</itemname>
<knowhow>1</knowhow>
<knowhow>2</knowhow>
<knowhow>3</knowhow>
<knowhow>4</knowhow>
<supervisor>1</supervisor>
<supervisor>2</supervisor>
<supervisor>3</supervisor>
<supervisor>4</supervisor>
</item>
</swobs>
如果我试试这个:
public void LoadXML() {
string myXMLfile = Server.MapPath("~/swobs.xml");
DataSet dssowbs = new DataSet();
try
{
dssowbs.ReadXml(myXMLfile);
DropDownList1.DataSource = dssowbs;
DropDownList1.DataValueField = "knowledge";
DropDownList1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
它抛出一个错误。