XML和帮助ASPX [英] Help with XML & ASPX

查看:56
本文介绍了XML和帮助ASPX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.我是使用XML的新手.我制作XML文件没有问题,但是我完全不知道如何在我的网页中实现它.我有一个列表框控件,我希望它基于子集"/节点显示它的列表项? XML文件中的一个标签.
例如:

Hi. I am new to using XML. I have no problem making XML files but i have completely no idea how to implement it in my web page. I have a listbox control and i want it to display it''s list items based on a ''subset''/node? of one tag in the XML file.
For example:

<animal>
    <cat>
        <fat_cat></fat_cat>
        <slim_cat></slim_cat>
    </cat>
    <dog>
        <fat_dog></fat_dog>
        <slim_dog></slim_dog>
    </dog>
</animal>



假设我希望列表框的内容为猫狗,并让另一个列表框根据第一个选择显示数据.因此,如果第一个列表框的选择是dog,则第二个列表框将显示fat_dog和list_box.我知道这是一个很大的要求,但如果可以的话,请帮助我.谢谢.干杯:-D



Say i want the items of the listbox to be dog and cat and have another listbox display data based on the first selection. So if the first list box''s selection is dog the second listbox displays fat_dog and list_box. I know this is a big request but if you can please help me. Thanks. Cheers :-D

推荐答案

请参阅本文,希望找到解决方法

使用XML的列表控件数据绑定 [
Refer this article, hope finds a solution

List Control Data Binding using XML[^]


hi,

我尝试了一些代码来读取您的xml文件,然后将值分配给列表框为



I tried some code for reading your xml file add assign the values to listbox is

XmlTextReader reader = new XmlTextReader(Server.MapPath("~/SomeFiles") + "/" + "XMLFile4.xml");
          reader.WhitespaceHandling = WhitespaceHandling.None;

          XmlDocument xmldoc = new XmlDocument();
          xmldoc.Load(reader);
          XmlNodeList xmlnodeli = xmldoc.GetElementsByTagName("animal");

          for (int i = 0; i <= xmlnodeli.Count; i++)
          {
              ListBox1.Items.Add(xmlnodeli[0].ChildNodes[i].Name);
          }



根据您的XML文件



According to your XML file

<animal>
	<cat>
		<fat_cat>dfgfd</fat_cat>
		<slim_cat>dfgfgfgfgdf</slim_cat>
	</cat>
	<dog>
		<fat_dog>dfgffgdfgd</fat_dog>
		<slim_dog>tytryt</slim_dog>
	</dog>
</animal>



我改进了此代码以更好地实现您的项目.如有疑问,请在此处发布
与您的代码.

一切顺利.



I improve this code for better implement your project.If any doubtds post here
with your code.

All the best.


这篇关于XML和帮助ASPX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆