Пример обработки XML на XLINQ
Правильная схема для этого XML будет вот такая. При обработке создается и обрабатывается вот такой XML.
1: Imports <xmlns:b="http://AirtsBankingCards.vb-net.com/">
.... ...
115: 'кеширование чтения профиля из базы
116: Dim UserPaymentProfile1 As System.Collections.Generic.List(Of GetOneUserPaymentProfileResult)
117: If Session("UserPaymentProfile") Is Nothing Then
118: Dim AirtsDB As New UserPaymentProfileDataContext()
119: Dim AirtsDB_MemoryBuf As System.Collections.Generic.List(Of GetOneUserPaymentProfileResult) = AirtsDB.GetOneUserPaymentProfile(New Guid(CheckUser1.id)).ToList
120: Session("UserPaymentProfile") = AirtsDB_MemoryBuf
121: End If
122: UserPaymentProfile1 = Session("UserPaymentProfile")
123: Dim BankingCards_xml As Collections.Generic.IEnumerable(Of XElement) = From AllColumn In UserPaymentProfile1 Select AllColumn.BankingCardsProfile
124: '
125: If BankingCards_xml(0) IsNot Nothing Then
126: BankingCards_xml(0).<b:VISA>.@b:Module = cb_VISA_Module.Text
127: BankingCards_xml(0).<b:VISA>.@b:Code = tx_VISA_Code.Text
128: BankingCards_xml(0).<b:VISA>.@b:Comission = tx_VISA_Comission.Text
129: BankingCards_xml(0).<b:VISA>.@b:DayLimit = tx_VISA_Daylimit.Text
130: BankingCards_xml(0).<b:VISA>.@b:MounthLimit = tx_VISA_MounthLimit.Text
131: BankingCards_xml(0).<b:MC>.@b:Module = cb_MC_Module.Text
132: BankingCards_xml(0).<b:MC>.@b:Code = tx_MC_Code.Text
133: BankingCards_xml(0).<b:MC>.@b:Comission = tx_MC_Comission.Text
134: BankingCards_xml(0).<b:MC>.@b:DayLimit = tx_MC_Daylimit.Text
135: BankingCards_xml(0).<b:MC>.@b:MounthLimit = tx_MC_MounthLimit.Text
136: BankingCards_xml(0).<b:JCB>.@b:Module = cb_JCB_Module.Text
137: BankingCards_xml(0).<b:JCB>.@b:Code = tx_JCB_Code.Text
138: BankingCards_xml(0).<b:JCB>.@b:Comission = tx_JCB_Comission.Text
139: BankingCards_xml(0).<b:JCB>.@b:DayLimit = tx_JCB_DayLimit.Text
140: BankingCards_xml(0).<b:JCB>.@b:MounthLimit = tx_JCB_MounthLimit.Text
141: BankingCards_xml(0).<b:DCL>.@b:Module = cb_DCL_Module.Text
142: BankingCards_xml(0).<b:DCL>.@b:Code = tx_DCL_Code.Text
143: BankingCards_xml(0).<b:DCL>.@b:Comission = tx_DCL_Comission.Text
144: BankingCards_xml(0).<b:DCL>.@b:DayLimit = tx_DCL_DayLimit.Text
145: BankingCards_xml(0).<b:DCL>.@b:MounthLimit = tx_DCL_MounthLimit.Text
146: BankingCards_xml(0).<b:AMEX>.@b:Module = cb_AMEX_Module.Text
147: BankingCards_xml(0).<b:AMEX>.@b:Code = tx_AMEX_Code.Text
148: BankingCards_xml(0).<b:AMEX>.@b:Comission = tx_AMEX_Comission.Text
149: BankingCards_xml(0).<b:AMEX>.@b:DayLimit = tx_AMEX_DayLimit.Text
150: BankingCards_xml(0).<b:AMEX>.@b:MounthLimit = tx_AMEX_MounthLimit.Text
151: '
152: UserPaymentProfile1(0).BankingCardsProfile = BankingCards_xml(0)
153: '
154: Dim AirtsDB1 As New UserPaymentProfileDataContext()
155: AirtsDB1.SaveBankingCardsUserProfile(New Guid(CheckUser1.id), BankingCards_xml(0))
156: Else
157: Dim NewXML As New XElement(<b:BankingCards/>)
158: NewXML.Add(<b:VISA/>)
159: NewXML.Add(<b:MC/>)
160: NewXML.Add(<b:JCB/>)
161: NewXML.Add(<b:DCL/>)
162: NewXML.Add(<b:AMEX/>)
163: '
164: NewXML.<b:VISA>.@b:Module = cb_VISA_Module.Text
165: NewXML.<b:VISA>.@b:Code = tx_VISA_Code.Text
166: NewXML.<b:VISA>.@b:Comission = tx_VISA_Comission.Text
167: NewXML.<b:VISA>.@b:DayLimit = tx_VISA_Daylimit.Text
168: NewXML.<b:VISA>.@b:MounthLimit = tx_VISA_MounthLimit.Text
169: NewXML.<b:MC>.@b:Module = cb_MC_Module.Text
170: NewXML.<b:MC>.@b:Code = tx_MC_Code.Text
171: NewXML.<b:MC>.@b:Comission = tx_MC_Comission.Text
172: NewXML.<b:MC>.@b:DayLimit = tx_MC_Daylimit.Text
173: NewXML.<b:MC>.@b:MounthLimit = tx_MC_MounthLimit.Text
174: NewXML.<b:JCB>.@b:Module = cb_JCB_Module.Text
175: NewXML.<b:JCB>.@b:Code = tx_JCB_Code.Text
176: NewXML.<b:JCB>.@b:Comission = tx_JCB_Comission.Text
177: NewXML.<b:JCB>.@b:DayLimit = tx_JCB_DayLimit.Text
178: NewXML.<b:JCB>.@b:MounthLimit = tx_JCB_MounthLimit.Text
179: NewXML.<b:DCL>.@b:Module = cb_DCL_Module.Text
180: NewXML.<b:DCL>.@b:Code = tx_DCL_Code.Text
181: NewXML.<b:DCL>.@b:Comission = tx_DCL_Comission.Text
182: NewXML.<b:DCL>.@b:DayLimit = tx_DCL_DayLimit.Text
183: NewXML.<b:DCL>.@b:MounthLimit = tx_DCL_MounthLimit.Text
184: NewXML.<b:AMEX>.@b:Module = cb_AMEX_Module.Text
185: NewXML.<b:AMEX>.@b:Code = tx_AMEX_Code.Text
186: NewXML.<b:AMEX>.@b:Comission = tx_AMEX_Comission.Text
187: NewXML.<b:AMEX>.@b:DayLimit = tx_AMEX_DayLimit.Text
188: NewXML.<b:AMEX>.@b:MounthLimit = tx_AMEX_MounthLimit.Text
189: '
190: UserPaymentProfile1(0).BankingCardsProfile = NewXML
191: '
192: Dim AirtsDB2 As New UserPaymentProfileDataContext()
193: AirtsDB2.SaveBankingCardsUserProfile(New Guid(CheckUser1.id), NewXML)
194: End If
195: ...
Comments (
)
Link to this page:
//www.vb-net.com/Linq/xlinq.htm
|