xml结构:
<IFCA.Net xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Applications>
<Application ID="Lease" Text="Mall360" Icon="icons_lease ifca-icon-lease-M-Lease">
<!--Lease360 模块菜单配置 -->
<Module ID="Lease_ProjectSettings" Text="项目资料" Icon="icons_lease ifca-icon-lease-XMZL">
<SystemData>
<DataType ID="Lease_ProjectSettings_ProSet_AreaOfTypeForLease" Text="计租面积类型">
<Data ID="ProSet_AreaOfStructure" Text="建筑面积"></Data>
<Data ID="ProSet_AreaOfUsable" Text="使用面积"></Data>
<Data ID="ProSet_ComprisingArea" Text="套内面积"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_ProSet_UnitLeaseType" Text="租赁单元类型">
<Data ID="ProSet_Office" Text="写字楼"></Data>
<Data ID="ProSet_Stores" Text="商铺"></Data>
<Data ID="ProSet_House" Text="住宅"></Data>
<Data ID="ProSet_Flat" Text="公寓"></Data>
<Data ID="ProSet_AdvertisementSpace" Text="广告位"></Data>
<Data ID="ProSet_Storage" Text="仓库"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_ProSet_BatchAdditionType" Text="租赁单元批量增加方式">
<Data ID="ProSet_SingleFloorAddition" Text="单层批量增加"></Data>
<Data ID="ProSet_MutiFloorAddition" Text="多层批量增加"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_ProSet_AdvertisementType" Text="广告位类型">
<Data ID="ProSet_Ad_Lamphouse" Text="灯箱"></Data>
<Data ID="ProSet_Ad_GuaPai" Text="挂牌"></Data>
<Data ID="ProSet_Ad_Sanmianfan" Text="三面翻"></Data>
<Data ID="ProSet_Ad_Lupai" Text="路牌"></Data>
<Data ID="ProSet_Ad_Diaopai" Text="吊牌"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_ProSet_UnitStatus" Text="单元状态">
<Data ID="UnitStatus_Active" Text="不可租"></Data>
<Data ID="UnitStatus_Available" Text="未租"></Data>
<Data ID="UnitStatus_Booked" Text="已预定"></Data>
<Data ID="UnitStatus_Leased" Text="已租"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_Field" Text="单元属性">
<Data ID="Lease_ProjectSettings_Field_UnitNo" Text="单元编码"></Data>
<Data ID="Lease_ProjectSettings_Field_FloorNo" Text="楼层"></Data>
<Data ID="Lease_ProjectSettings_Field_BusinessType" Text="商业类型"></Data>
<Data ID="Lease_ProjectSettings_Field_BuildUpArea" Text="建筑面积"></Data>
<Data ID="Lease_ProjectSettings_Field_InteriorArea" Text="套内面积"></Data>
<Data ID="Lease_ProjectSettings_Field_UsableArea" Text="使用面积"></Data>
<Data ID="Lease_ProjectSettings_Field_LeaseArea" Text="计算面积"></Data>
<Data ID="Lease_ProjectSettings_Field_UnitHeight" Text="高度"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_ProSet_ChangeType" Text="单元更改类型">
<Data ID="ProSet_ChangeType_Create" Text="增加"></Data>
<Data ID="ProSet_ChangeType_Modify" Text="修改"></Data>
<Data ID="ProSet_ChangeType_Split" Text="拆分"></Data>
<Data ID="ProSet_ChangeType_Merge" Text="合并"></Data>
<Data ID="ProSet_ChangeType_Remove" Text="删除"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_ProSet_Message" Text="单元消息">
<Data ID="Lease_ProjectSettings_Message_NoUnit" Text="暂无租赁单元"></Data>
<Data ID="Lease_ProjectSettings_Message_UnitNo" Text="单元编号"></Data>
<Data ID="Lease_ProjectSettings_Message_Area" Text="单元面积"></Data>
<Data ID="Lease_ProjectSettings_Message_ActiveDate" Text="启用日期"></Data>
<Data ID="Lease_ProjectSettings_Message_BusinessType" Text="商业类型"></Data>
<Data ID="Lease_ProjectSettings_Message_Row" Text="行"></Data>
<Data ID="Lease_ProjectSettings_Message_FloorInvalid" Text="楼层不合法!"></Data>
<Data ID="Lease_ProjectSettings_Message_UnitTypeInvalid" Text="租赁单元类型不合法!"></Data>
<Data ID="Lease_ProjectSettings_Message_AreaInvalid" Text="面积不合法!"></Data>
<Data ID="Lease_ProjectSettings_Message_HeightInvalid" Text="高度不合法!"></Data>
<Data ID="Lease_ProjectSettings_Message_AdTypeInvalid" Text="广告类型不合法!"></Data>
<Data ID="Lease_ProjectSettings_Message_AdPriceInvalid" Text="广告位价格不合法!"></Data>
<Data ID="Lease_ProjectSettings_Message_AdNoInvalid" Text="广告数量不合法!"></Data>
<Data ID="Lease_ProjectSettings_Message_UnitNoIsExists" Text="有相同的单元编号!"></Data>
<Data ID="Lease_ProjectSettings_Message_UnitNoIsExistsInCurrentFloor" Text="当前楼栋中已存在!"></Data>
<Data ID="Lease_ProjectSettings_Message_TheUnitCellNoIsExist" Text="当前单元序号内中已有单元存在!"></Data>
<Data ID="Lease_ProjectSettings_Message_Locate" Text="设置项目位置"></Data>
<Data ID="Lease_ProjectSettings_Message_ImportTemplete" Text="导入模板"></Data>
<Data ID="Lease_ProjectSettings_Message_SelectAll" Text="全选"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_BatchEditor" Text="单元批量修改">
<Data ID="Lease_ProjectSettings_BatchEditor_ModifyAll" Text="修改全部"></Data>
<Data ID="Lease_ProjectSettings_BatchEditor_ModifyRow" Text="修改整行"></Data>
<Data ID="Lease_ProjectSettings_BatchEditor_ModifyColumn" Text="修改整列"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_PropertyLeaseRatesMonth" Text="月份">
<Data ID="PropertyLeaseRatesMonth_OneMonth" Text="1月"></Data>
<Data ID="PropertyLeaseRatesMonth_TwoMonth" Text="2月"></Data>
<Data ID="PropertyLeaseRatesMonth_ThreeMonth" Text="3月"></Data>
<Data ID="PropertyLeaseRatesMonth_FourMonth" Text="4月"></Data>
<Data ID="PropertyLeaseRatesMonth_FiveMonth" Text="5月"></Data>
<Data ID="PropertyLeaseRatesMonth_SixMonth" Text="6月"></Data>
<Data ID="PropertyLeaseRatesMonth_SevenMonth" Text="7月"></Data>
<Data ID="PropertyLeaseRatesMonth_EightMonth" Text="8月"></Data>
<Data ID="PropertyLeaseRatesMonth_NineMonth" Text="9月"></Data>
<Data ID="PropertyLeaseRatesMonth_TenMonth" Text="10月"></Data>
<Data ID="PropertyLeaseRatesMonth_ElevenMonth" Text="11月"></Data>
<Data ID="PropertyLeaseRatesMonth_TwelveMonth" Text="12月"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_PropertyFinanceControlWebChart" Text="集团管控财务统计">
<Data ID="PropertyFinanceControl_DocumentAmt" Text="应收款"></Data>
<Data ID="PropertyFinanceControl_ReceiptAml" Text="实收款"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_PropertyRentalOccupancyWebChart" Text="项目出租率统计">
<Data ID="PropertyRental_RoomOccupancyRates" Text="出租率"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_PropertyVarietiesAvgLeaseAmtWebChart" Text="项目业态平均租金统计">
<Data ID="PropertyVarietiesAvgLeaseAm_AvgPrice" Text="租金"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_AreaUnit" Text="面积单位">
<Data ID="RT_centiare" Text="平方米"></Data>
<Data ID="RT_Squarefoot" Text="平方尺"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_RepeatTypes" Text="重复模式">
<Data ID="Repeated_Daily" Text="日常"></Data>
<Data ID="Repeated_Weekly" Text="每周"></Data>
<Data ID="Repeated_Monthly" Text="每月"></Data>
<Data ID="Repeated_Yearly" Text="每年"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_Days" Text="周">
<Data ID="ProSet_Days_Sun" Text="周日"></Data>
<Data ID="ProSet_Days_Mon" Text="周一"></Data>
<Data ID="ProSet_Days_Tues" Text="周二"></Data>
<Data ID="ProSet_Days_Wed" Text="周三"></Data>
<Data ID="ProSet_Days_Thur" Text="周四"></Data>
<Data ID="ProSet_Days_Fri" Text="周五"></Data>
<Data ID="ProSet_Days_Sat" Text="周六"></Data>
</DataType>
<DataType ID="Lease_ProjectSettings_Months" Text="月">
<Data ID="ProSet_Months_Jan" Text="一月"></Data>
<Data ID="ProSet_Months_Feb" Text="二月"></Data>
<Data ID="ProSet_Months_Mar" Text="三月"></Data>
<Data ID="ProSet_Months_Apr" Text="四月"></Data>
<Data ID="ProSet_Months_May" Text="五月"></Data>
<Data ID="ProSet_Months_Jun" Text="六月"></Data>
<Data ID="ProSet_Months_Jul" Text="七月"></Data>
<Data ID="ProSet_Months_Aug" Text="八月"></Data>
<Data ID="ProSet_Months_Sep" Text="九月"></Data>
<Data ID="ProSet_Months_Oct" Text="十月"></Data>
<Data ID="ProSet_Months_Nov" Text="十一月"></Data>
<Data ID="ProSet_Months_Dec" Text="十二月"></Data>
</DataType>
</SystemData>
<DataEntities>
<!--BlockDetail页面FormEditor的SysKey-->
<DataEntity ID="Lease_ProjectSettings_BlockDetailContract" Text="楼栋明细">
<Property ID="Lease_ProjectSettings_BlockDetailContract_Basic" Key="Basic" Type="System.String" Text="基本信息" />
<Property ID="Lease_ProjectSettings_BlockDetailContract_BlockNo" Key="BlockNo" Type="System.String" Text="楼栋编号" />
<Property ID="Lease_ProjectSettings_BlockDetailContract_BlockName" Key="BlockName" Type="System.String" Text="楼栋名称" />
<Property ID="Lease_ProjectSettings_BlockDetailContract_UnitNoBuildType" Key="UnitNoBuildTypeID" Type="System.Int32" Text="单元号方式" />
<Property ID="Lease_ProjectSettings_BlockDetailContract_TotalArea" Key="TotalArea" Type="System.Double" Text="总面积" />
<Property ID="Lease_ProjectSettings_BlockDetailContract_BuildingArea" Key="BuildingArea" Type="System.Double" Text="建筑面积" />
<Property ID="Lease_ProjectSettings_BlockDetailContract_UsableArea" Key="UsableArea" Type="System.Double" Text="使用面积" />
</DataEntities>
</Module>
</Application>
</Applications>
</IFCA.Net>
解析类:
private static readonly string FilePath = ""; //xml路径
private static Dictionary<string, string> GetKeyValue()
{
DicKv.Clear();
var xmlDoc = new XmlDocument();
xmlDoc.Load(FilePath);
XmlNode xn = xmlDoc.SelectSingleNode("/IFCA.Net");
if (xn != null)
{
RecursiveXml(xn);
}
return DicKv;
}
//存储键/值字典表
public static Dictionary<string, string> DicKv = new Dictionary<string, string>();
//递归找每个节点
private static void RecursiveXml(XmlNode xn)
{
XmlNodeList xnl = xn.ChildNodes;
foreach (XmlNode item in xnl)
{
try
{
if (item.Attributes != null && item.Attributes.Count > 0 && CheckAttrExist(item, "ID"))
{
string id = item.Attributes["ID"].Value; if (string.IsNullOrEmpty(id) || DicKv.ContainsKey(id)) continue;
if (CheckAttrExist(item, "Text"))
{
DicKv.Add(id, item.Attributes["Text"].Value);
}
else
{
DicKv.Add(id, "");
}
}
if (item.HasChildNodes) { RecursiveXml(item); }
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
} //检查某xml属性是否存在
private static bool CheckAttrExist(XmlNode xn, string attrName)
{
if (xn == null || xn.Attributes == null || xn.Attributes.Count == 0) return false; bool result = false; foreach (XmlAttribute xa in xn.Attributes)
{
if (xa.Name == attrName)
{
result = true; break;
}
}
return result;
}