| With NodeList for i as integer=0 to .Count-1 Dim objson as clsA/B=colA/B.GenerateAson objson.Name1=.item(i).childnodes(x1).innertext objson.Name2=.item(i).childnodes(x2).innertext ...... ...... ...... colA/B.Addson(objson) next i End With |
| Public Shared Function FillFromXml(ByVal NodeName As String, ByVal strPath As String, ByVal objFather As Object) As Boolean Try With xmlGetList(NodeName, strPath) For i As Integer = 0 To .Count - 1 Dim st As Object = objFather.GenerateAson Dim ty As Type = st.GetType For Each pp As PropertyInfo In ty.GetProperties With DirectCast(.Item(i), XmlElement) If .SelectSingleNode(pp.Name.ToUpper) IsNot Nothing Then pp.SetValue(st, CType(.SelectSingleNode(pp.Name.ToUpper).InnerText.Trim, String), Nothing) End If End With Next objFather.AddSon(st) Next End With Return True Catch ex As Exception Return False End Try End Function |