满意的工作就是对它感兴趣

希望和大家一起研究,并沉醉其中

博客园 首页 新随笔 联系 订阅 管理

获取XML信息 
public ArrayList getXML(string path)
    {
        try
        {
            XmlDocument doc1 = new XmlDocument();
            doc1.Load(Server.MapPath(path));
            XmlNodeList node = doc1.DocumentElement.ChildNodes;
            ArrayList al = new ArrayList();
            foreach (XmlNode n1 in node)
            {
                Table t = new Table();
                XmlNodeList node1 = n1.ChildNodes;
                foreach (XmlNode nodeChild in node1)
                {
                    bool a = nodeChild.HasChildNodes;//垃圾属性

                    if (nodeChild.Name == "tableName")
                    {
                        XmlElement xe = (XmlElement)nodeChild;

                        t.TableName = xe.InnerText.ToString();

                    }
                    if (nodeChild.Name == "KEYWORD")
                    {
                        XmlElement xe = (XmlElement)nodeChild;
                        //if(xe.Name=="niandu")
                        t.KEYWORD +=  xe.InnerText.ToString()+"," ;

                    }
                    if (nodeChild.Name == "column")
                    {
                        XmlNodeList nodeColumn = nodeChild.ChildNodes;
                        Column column = new Column();
                        foreach (XmlNode child in nodeColumn)
                        {
                            XmlElement xeChild = (XmlElement)child;
                            if (child.Name == "columnName")
                            {
                                column.columnName = xeChild.InnerText.ToString();
                            }
                            if (child.Name.Length > 6 && child.Name.Substring(0, 6) == "Column")
                            {
                                column.allColumn.Add(xeChild.InnerText.ToString());
                            }
                            if (child.Name == "cnName")
                            {
                                column.cnName = xeChild.InnerText.ToString();
                            }
                            if (child.Name == "Method")
                            {
                                column.method = xeChild.InnerText.ToString();
                            }
                            if (child.Name == "type")
                            {
                                column.type = xeChild.InnerText.ToString();
                            }
                        }
                        t.alColumn.Add(column);
                    }

                }
                al.Add(t);

            }
            return al;
        }
        catch { return null; }
    }
//hashtable
 foreach (object key in ht.Keys)
            {
                Response.Write(ht[key] + "<br>");
                Response.Write(key.ToString() + "<br>");
            }  

posted on 2007-02-05 12:40  半瓶之迷迷糊糊  阅读(129)  评论(0)    收藏  举报