读取XML文件

 通过读取XML配置文件以哈希表结构进行保存。

 

Dim strMapInfoPath As String = System.Windows.Forms.Application.StartupPath() + "/MapConfiguration/DJTFHDMList.XML"
            Dim doc As XmlDocument = New XmlDocument
            If File.Exists(strMapInfoPath) Then
                doc.Load(strMapInfoPath)
                Dim rootNode As XmlNode = doc.Item("DJTFHDMList")
                If rootNode Is Nothing Then
                    Return
                End If

                '取XML的节点
                For Each featureCodeNode As XmlNode In rootNode.ChildNodes
                    Dim ClassLayerParameter As LayerParameter = New LayerParameter()
                    ClassLayerParameter.LayerName = featureCodeNode.Attributes("LayerName").Value
                    ClassLayerParameter.AliasName = featureCodeNode.Attributes("AliasName").Value
                    '属性字段
                    Dim attributesNode As XmlNode = featureCodeNode.Item("FHDMMappings")
                    If Not attributesNode Is Nothing Then
                        For Each attributesSubNode As XmlNode In attributesNode.ChildNodes
                            Dim ClassFieidsFHDMParameter As FieidsFHDMParameter = New FieidsFHDMParameter()
                            ClassFieidsFHDMParameter.FHDM = attributesSubNode.Attributes("FHDM").Value
                            ClassFieidsFHDMParameter.FHDMName = attributesSubNode.Attributes("FHDMName").Value
                            ClassFieidsFHDMParameter.Status = attributesSubNode.Attributes("Status").Value
                            ClassLayerParameter.PutFieidsFHDMParameter(ClassFieidsFHDMParameter.FHDM, ClassFieidsFHDMParameter)
                        Next
                    End If
                    m_hasTable.Add(ClassLayerParameter.LayerName, ClassLayerParameter)
                Next
            Else
                MsgBox("找不到相关的文件", MsgBoxStyle.Information, "提示")
            End If

        Catch ex As Exception
            MessageFactory.MessageService.ShowInformation("加载配置文件出错!")
        End Try

 

配置文件样式:

<DJTFHDMList>
  <LayerCode LayerName="CLKZD" AliasName="测量控制点">
    <FHDMMappings>
      <FHDMMappings FHDM="110102" FHDMName="三角点" Status="True" />
      <FHDMMappings FHDM="110104" FHDMName="土堆上的三角点" Status="True" />
      <FHDMMappings FHDM="110105" FHDMName="小三角点" Status="True" />
      <FHDMMappings FHDM="110106" FHDMName="土堆上的小三角点" Status="True" />
    </FHDMMappings>
  </LayerCode>

</DJTFHDMList>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值