XML --> ArrayList --> ListBox

// 创建XmlDocument类的实例
   XmlDocument doc = new XmlDocument();
   ArrayList NodeValues = new ArrayList();
   // 把people.xml文件读入内存,形成一个DOM结构
   doc.Load( Server.MapPath("people.xml") );
   XmlNode root = doc.DocumentElement;
   foreach( XmlNode personElement in root.ChildNodes )
    //NodeValues.Add(personElement.FirstChild.Value);
    NodeValues.Add(personElement.InnerText);

   XMLNodeListBox.DataSource = NodeValues;
   XMLNodeListBox.DataBind();

<?xml version="1.0" encoding="utf-8" ?>
  <PEOPLE>
    <PERSON>张三</PERSON>
    <PERSON>李四</PERSON>
  </PEOPLE>

posted @ 2006-10-23 10:27  RobotTech  阅读(332)  评论(0编辑  收藏  举报