在ASP.NET MVC中的Html.DropDownList中显示XML文件内容 [英] Displaying XML file contents in Html.DropDownList in asp.net mvc

查看:85
本文介绍了在ASP.NET MVC中的Html.DropDownList中显示XML文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个xml文件



<?xml version ="1.0" encoding ="utf-8"?>
< CRM>
< Unit ID ="1" Name =آذربایجانشرقی">
< city ID ="1">آذرشهر</city>
< city ID ="2">اسکو</city>
< city ID ="3">اهر</city>
< city ID ="12">کلیبر</city>
< city ID ="13">مراغه</city>
< city ID ="14">مرند</city>
< city ID ="15">ملکان</city>
< city ID ="16">ملکان</city>
< city ID ="17">میانه</city>
< city ID ="18">ورزقان</city>
< city ID ="19">هریس</city>
< city ID ="20">هشترود</city>
</Unit>

< Unit ID ="2" Name =آذربایجانغربی">
< city ID ="1">ارومیه</city>
< city ID ="2">اشنویه</city>
< city ID ="3">بوکان</city>
< city ID ="4">پیرانشهر</city>
< city ID ="5">تکاب</city>
< city ID ="6">چالدران</city>
</Unit>

< Unit ID ="3" Name =اردبیل">
< city ID ="1">اردبیل</city>
< city ID ="2"> بیله‌سوار</city>
</Unit>

< Unit ID ="4" Name =اصفهان">
< city ID ="1">آرانوبیدگل</city>
< city ID ="2">اردستان</city>
< city ID ="3">اصفهان</city>
< city ID ="4">برخوارومیمه</city>
< city ID ="5">تیرانوکرون</city>
< city ID ="6">چادگان</city>
< city ID ="7"> خمینی‌شهر</city>
< city ID ="8">خوانسار</city>
< city ID ="9">سمیرم</city>
< city ID ="10">شهرضا</city>
< city ID ="11">سمیرمسفلی</city>
< city ID ="12">فریدن</city>
</Unit>
</CRM>


我在html.dropdownlist
中显示列表名称单元 我该怎么办?

i have this xml file



<?xml version="1.0" encoding="utf-8"?>
<CRM>
<Unit ID="1" Name="آذربایجان شرقی">
<city ID="1">آذرشهر </city>
<city ID="2">اسکو </city>
<city ID="3">اهر </city>
<city ID="12">کلیبر </city>
<city ID="13">مراغه </city>
<city ID="14">مرند </city>
<city ID="15">ملکان </city>
<city ID="16">ملکان </city>
<city ID="17">میانه </city>
<city ID="18">ورزقان </city>
<city ID="19">هریس </city>
<city ID="20">هشترود</city>
</Unit>

<Unit ID="2" Name="آذربایجان غربی">
<city ID="1">ارومیه </city>
<city ID="2">اشنویه </city>
<city ID="3">بوکان </city>
<city ID="4">پیرانشهر </city>
<city ID="5">تکاب </city>
<city ID="6">چالدران </city>
</Unit>

<Unit ID="3" Name="اردبیل">
<city ID="1">اردبیل </city>
<city ID="2">بیله‌سوار </city>
</Unit>

<Unit ID="4" Name="اصفهان">
<city ID="1">آران و بیدگل</city>
<city ID="2">اردستان </city>
<city ID="3">اصفهان </city>
<city ID="4">برخوار و میمه</city>
<city ID="5">تیران و کرون</city>
<city ID="6">چادگان </city>
<city ID="7">خمینی‌شهر </city>
<city ID="8">خوانسار </city>
<city ID="9">سمیرم </city>
<city ID="10">شهرضا"</city>
<city ID="11">سمیرم سفلی"</city>
<city ID="12">فریدن"</city>
</Unit>
</CRM>


I''m showing list name unit in html.dropdownlist
what should i do?

推荐答案

您的XML显示了两个层次结构.这意味着您应该使用树形视图而不是列表.为什么会有问题?

—SA
Your XML shows two levels of hierarchy. It means you should use tree view instead of list. Why this is a problem?

—SA


这篇关于在ASP.NET MVC中的Html.DropDownList中显示XML文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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