asp.net如何读取xml
<?xml version="1.0" encoding="utf-8" ?>- <root>
- <!-- 项目:id为唯一标识,name为项目名称
-->
- <project id="01" name="熙街一期">
- <!-- 楼栋,ID为唯一标识,name为楼栋名称
-->
- <building name="东大楼" id="1">
- <!-- 楼层,name为楼层名称
-->
- <floor name="1">
- <!-- 单元,name为单元名称
-->
- <unit name="01">
- <!-- UnityID这是虚拟现实房间编号
-->
- <!-- 房间,id为房间唯一标识
-->
- -->
<room UnityID="1" id="47" name="101" Prerentconstructionarea="1600" Actualconstructionarea="1600" Prerentsetinsidearea="1500" Measuredsetinsidearea="1500" Constructionarea="1600" Setinsidearea="1400" Valuationway="建筑面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="很好,业主不错的选择" Status="小订" PlanUrl="" Proprietor="潭波" ShopName="中国农业银行" />
<room UnityID="1" id="48" name="102" Prerentconstructionarea="2000" Actualconstructionarea="2000" Prerentsetinsidearea="1890" Measuredsetinsidearea="1890" Constructionarea="2000" Setinsidearea="1800" Valuationway="套内面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="" Status="签约" PlanUrl="" Proprietor="老李" ShopName="永辉超市" />
</unit>
+ <unit name="02">
<room UnityID="1" id="49" name="101" Prerentconstructionarea="1600" Actualconstructionarea="1600" Prerentsetinsidearea="1500" Measuredsetinsidearea="1500" Constructionarea="1600" Setinsidearea="1400" Valuationway="建筑面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="很好,业主不错的选择" Status="小订" PlanUrl="" Proprietor="潭波" ShopName="中国农业银行" />
<room UnityID="1" id="50" name="102" Prerentconstructionarea="2000" Actualconstructionarea="2000" Prerentsetinsidearea="1890" Measuredsetinsidearea="1890" Constructionarea="2000" Setinsidearea="1800" Valuationway="套内面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="" Status="签约" PlanUrl="" Proprietor="老李" ShopName="永辉超市" />
</unit>
</floor>
+ <floor name="2">
+ <unit name="01">
<room UnityID="1" id="47" name="101" Prerentconstructionarea="1600" Actualconstructionarea="1600" Prerentsetinsidearea="1500" Measuredsetinsidearea="1500" Constructionarea="1600" Setinsidearea="1400" Valuationway="建筑面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="很好,业主不错的选择" Status="小订" PlanUrl="" Proprietor="潭波" ShopName="中国农业银行" />
<room UnityID="1" id="48" name="102" Prerentconstructionarea="2000" Actualconstructionarea="2000" Prerentsetinsidearea="1890" Measuredsetinsidearea="1890" Constructionarea="2000" Setinsidearea="1800" Valuationway="套内面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="" Status="签约" PlanUrl="" Proprietor="老李" ShopName="永辉超市" />
</unit>
+ <unit name="02">
<room UnityID="1" id="49" name="101" Prerentconstructionarea="1600" Actualconstructionarea="1600" Prerentsetinsidearea="1500" Measuredsetinsidearea="1500" Constructionarea="1600" Setinsidearea="1400" Valuationway="建筑面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="很好,业主不错的选择" Status="小订" PlanUrl="" Proprietor="潭波" ShopName="中国农业银行" />
<room UnityID="1" id="50" name="102" Prerentconstructionarea="2000" Actualconstructionarea="2000" Prerentsetinsidearea="1890" Measuredsetinsidearea="1890" Constructionarea="2000" Setinsidearea="1800" Valuationway="套内面积" Decoratingastandard="" Decorateunitprice="" Decorateaparagraph="" Constructionunitprice="2" Setinsidetheunitprice="2" Standardprice="4" Familycommenton="" Status="签约" PlanUrl="" Proprietor="老李" ShopName="永辉超市" />
</unit>
</floor>
</building>
- <building name="西大楼" id="2">
+ <floor name="1">
+ <unit name="01">
<room UnityID="1" id="47" name="101" />
<room UnityID="1" id="48" name="102" />
</unit>
- <unit name="02">
</unit>
</floor>
+ <floor name="2">
+ <unit name="01">
</unit>
- <unit name="02">
</unit>
</floor>
</building>
</project>
+ <project id="02" name="熙街二期">
+ <building name="东大楼" id="1">
+ <floor name="1">
+ <unit name="01">
</unit>
- <unit name="02">
</unit>
</floor>
- <floor name="2">
- <unit name="01">
</unit>
- <unit name="02">
</unit>
</floor>
</building>
+ <building name="西大楼" id="2">
+ <floor name="1">
- <unit name="01">
</unit>
- </floor>
- </building>
</project>
</root>
这种怎么读取, 我想先读取root下的所有project节点 在页面上展示“熙街一期","熙街二期"等用table 或者用repeater控件展示 在通过点击”一期“或则其他 进入另一个页面 显示下一节点 然后在读取building 节点 展示 在点击 --------------------编程问答-------------------- 用dataset或者xmldatadocument都可以对xml进行读取。 --------------------编程问答-------------------- XmlDocument xml = new XmlDocument();
xml.Load("XXXX.xml");
XmlNodeList xmlNodeList = xmlLoad.SelectNodes("root/project [id='1']");//查找root下 id=1的节点
XmlNode xmlNode = xmlNodeList.Item(0);
string txt = xmlNode["name"].InnerText;//显示 东大楼 --------------------编程问答-------------------- 最简单的,datatable aa= xx.readXml(); --------------------编程问答-------------------- 你可以参考类似的方法
http://dotnet.aspx.cc/file/DataSource-Xml-Nested-DataBinding.aspx --------------------编程问答-------------------- LZ去我的博客看看吧 写的很详细 --------------------编程问答-------------------- 跟着学习学习 --------------------编程问答-------------------- 我也想知道 --------------------编程问答-------------------- linq to xml
补充:.NET技术 , ASP.NET