将xml多个相同下节点的分类获取 C#

<InformationVersion="1.0.1"><SoftWare><Browsers><DefaultBrowser>...</DefaultBrowser><... <Information Version="1.0.1">
<SoftWare>
<Browsers>
<DefaultBrowser>...</DefaultBrowser>
<Browser>
<Name>Mozilla Firefox</Name>
<Version>25.0.1</Version>
<HomePage>about:cehome</HomePage>
<SearchEngines>
<DefaultSearchEngine>
<Name>�ٶ�</Name>
</DefaultSearchEngine>
<SearchEngine>
<Name>卓越亚马逊</Name>
</SearchEngine>
<SearchEngine>
<Name>百度</Name>
</SearchEngine>
<SearchEngine>
<Name>Google</Name>
</SearchEngine>
<SearchEngine>
<Name>淘宝购物</Name>
</SearchEngine>
<SearchEngine>
<Name>当当网</Name>
</SearchEngine>
<SearchEngine>
<Name>有道</Name>
</SearchEngine>
<SearchEngine>
<Name>百度知道</Name>
</SearchEngine>
<SearchEngine>
<Name>Bing</Name>
</SearchEngine>
<SearchEngine>
<Name>Creative Commons</Name>
</SearchEngine>
<SearchEngine>
<Name>易趣网</Name>
</SearchEngine>
<SearchEngine>
<Name>拍拍网</Name>
</SearchEngine>
<SearchEngine>
<Name>维基百科</Name>
</SearchEngine>
</SearchEngines>
<Plugins>...</Plugins>
</Browser>
<Browser>
<Name>Google Chrome</Name>
<Version>38.0.2125.104</Version>
<HomePage/>
<SearchEngines>
<DefaultSearchEngine>
<Name>Google</Name>
</DefaultSearchEngine>
<SearchEngine>
<Name>百度</Name>
</SearchEngine>
<SearchEngine>
<Name>搜狗</Name>
</SearchEngine>
<SearchEngine>
<Name>Bing</Name>
</SearchEngine>
</SearchEngines>
<Plugins/>
</Browser>
</Browsers>
</SoftWare>
</Information>

补充:如何获取SoftWare/Browsers/Browser下的HomePage和SearchEngines,并把Firefox的HomePage放在richtextbox1中,Google的HomePage放在richtextbox2中,Firefox同节点里的SearchEngine添加到combobox1,Google添加到combobox2中去。
展开
 我来答
玩转数据处理
推荐于2017-11-26 · 数据处理,Python,dotnet
玩转数据处理
采纳数:1613 获赞数:3794

向TA提问 私信TA
展开全部
//数据都帮你取出来完了,摆控件赋值自个弄弄就好了
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace XMLTest
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlDocument xml = new XmlDocument();
            xml.Load("aa.xml");
            XmlNode xe = xml.SelectSingleNode("Information/SoftWare/Browsers");
            foreach (XmlNode item in xe.ChildNodes)
            {
                if (item.Name == "Browser")
                {
                    if (item.SelectSingleNode("Name").InnerText == "Mozilla Firefox")
                    {
                        Console.WriteLine(item.SelectSingleNode("Name").InnerText);
                        Console.WriteLine(item.SelectSingleNode("Version").InnerText);
                        Console.WriteLine(item.SelectSingleNode("HomePage").InnerText);
                        XmlNode searchEnginesNode = item.SelectSingleNode("SearchEngines");
                        foreach (XmlNode itemEngine in searchEnginesNode.ChildNodes)
                        {
                            Console.WriteLine(itemEngine.SelectSingleNode("Name").InnerText);
                        }
                    }
                    else if (item.SelectSingleNode("Name").InnerText == "Google Chrome")
                    {
                        Console.WriteLine(item.SelectSingleNode("Name").InnerText);
                        Console.WriteLine(item.SelectSingleNode("Version").InnerText);
                        Console.WriteLine(item.SelectSingleNode("HomePage").InnerText);
                        XmlNode searchEnginesNode = item.SelectSingleNode("SearchEngines");
                        foreach (XmlNode itemEngine in searchEnginesNode.ChildNodes)
                        {
                            Console.WriteLine(itemEngine.SelectSingleNode("Name").InnerText);
                        }
                    }
                }
            }
            Console.ReadKey();
        }
    }
}
追问
嗯,已经做出来,还是谢谢你!
追答
...........................................
看作业
2014-10-27 · 贡献了超过105个回答
知道答主
回答量:105
采纳率:50%
帮助的人:12.8万
展开全部
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/Config/BusinessCategory.xml"));
XmlElement rootElem = xmlDoc.DocumentElement; //获取根节点
XmlNodeList BusinessCategoryNodes = rootElem.GetElementsByTagName("BusinessCategory");
string html = "";
List<BusinessTypeOptions> _lBusinessTypeOptions = new List<BusinessTypeOptions>();
_lBusinessTypeOptions = obj_BusinessTypeOptions.GetByCategoryID(CategoryID);
foreach (XmlNode node in BusinessCategoryNodes)
{
}
读取XML
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式