本文介绍了将xml子节点读取到我的sql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读取到带有sql数据库的子节点的xml

i want to read my xml with child node to sql database

推荐答案

报价:



昏暗的xDoc = XDocument.Load(feedUrl)

"对于xDoc.Descendants("category")中的每个类别

''尝试

" Dim lName As String = category.Attribute("name").Value
''Dim LeagueName()作为字符串
''LeagueName = Split(lName,:",2)

" Dim LeagueId As String = category.Attribute("id").Value


''Dim minutesToExpiry As Int16 = 5
"对于xDoc.Descendants("match")中的每个匹配

''尝试
" Dim matchId为整数= Val(match.Attribute("id").Value)
" Dim matchDate As DateTime = CDate(String.Format("{0}/{1}/{2} {3}",_
''match.Attribute("date").Value.Split(")(1),_
''match.Attribute("date").Value.Split(")(0),_
''match.Attribute("formatted_date").Value.Split(.")(2),_
''match.Attribute("time").Value))
''matchDate = matchDate.AddHours(1)''GMT +1

" Dim match_formdate As Date = match.Attribute("formatted_date").Value
" Dim match_time As Date = match.Attribute("time").Value
" Dim gsm_id为整数= match.Attribute("fix_id").Value
" Dim matchStatus As String = match.Attribute("status")
''Dim homeId As String = match.Descendants("localteam")(0).Attribute("id").Value
"如果homeId ="然后
''homeId = 0
''结束如果

''将homeTeamId设为整数= CInt(homeId)
''Dim homeTeam As String = match.Descendants("localteam")(0).Attribute("name").Value

''Dim awayId As String = match.Descendants("visitorteam")(0).Attribute("id").Value
"如果awayId ="然后
''awayId = 0
''结束如果
''Dim awayTeamId为整数= CInt(awayId)
''Dim awayTeam As String = match.Descendants("visitorteam")(0).Attribute("name").Value

" Dim uniqueId作为String = String.Format("{0:yyyyMMddHHss} {1} {2}",matchDate,homeTeamId,awayTeamId)
''Dim expiryDate As DateTime = matchDate.AddMinutes(-1 * minutesToExpiry)

''Dim entby As String =用户"
"如果match.Descendants("localteam")(0).Attribute("goals").Value.Length> 0然后

''Dim homeTeamScor As String = match.Descendants("localteam")(0).Attribute("goals").Value
''Dim awayTeamScor As String = match.Descendants("visitorteam")(0).Attribute("goals").Value

"如果homeTeamScor =?"然后
''homeTeamScor ="0"
''结束如果
"如果awayTeamScor =?"然后
" awayTeamScor ="0"
''结束如果
''homeTeamScore = CInt(homeTeamScor)
''awayTeamScore = CInt(awayTeamScor)
''结束如果

"如果match.Descendants("events").Elements.Count> 0然后

''如果结束



Dim xDoc = XDocument.Load(feedUrl)

''For Each category In xDoc.Descendants("category")

'' '' Try

'' Dim lName As String = category.Attribute("name").Value
'' Dim leagueName() As String
'' leagueName = Split(lName, ":", 2)

'' Dim leagueId As String = category.Attribute("id").Value


'' Dim minutesToExpiry As Int16 = 5
'' For Each match In xDoc.Descendants("match")

'' ''Try
'' Dim matchId As Integer = Val(match.Attribute("id").Value)
'' Dim matchDate As DateTime = CDate(String.Format("{0}/{1}/{2} {3}", _
'' match.Attribute("date").Value.Split(" ")(1), _
'' match.Attribute("date").Value.Split(" ")(0), _
'' match.Attribute("formatted_date").Value.Split(".")(2), _
'' match.Attribute("time").Value))
'' matchDate = matchDate.AddHours(1) '' GMT + 1

'' Dim match_formdate As Date = match.Attribute("formatted_date").Value
'' Dim match_time As Date = match.Attribute("time").Value
'' Dim gsm_id As Integer = match.Attribute("fix_id").Value
'' Dim matchStatus As String = match.Attribute("status")
'' Dim homeId As String = match.Descendants("localteam")(0).Attribute("id").Value
'' If homeId = "" Then
'' homeId = 0
'' End If

'' Dim homeTeamId As Integer = CInt(homeId)
'' Dim homeTeam As String = match.Descendants("localteam")(0).Attribute("name").Value

'' Dim awayId As String = match.Descendants("visitorteam")(0).Attribute("id").Value
'' If awayId = "" Then
'' awayId = 0
'' End If
'' Dim awayTeamId As Integer = CInt(awayId)
'' Dim awayTeam As String = match.Descendants("visitorteam")(0).Attribute("name").Value

'' Dim uniqueId As String = String.Format("{0:yyyyMMddHHss}{1}{2}", matchDate, homeTeamId, awayTeamId)
'' Dim expiryDate As DateTime = matchDate.AddMinutes(-1 * minutesToExpiry)

'' Dim entby As String = "user"
'' If match.Descendants("localteam")(0).Attribute("goals").Value.Length > 0 Then

'' Dim homeTeamScor As String = match.Descendants("localteam")(0).Attribute("goals").Value
'' Dim awayTeamScor As String = match.Descendants("visitorteam")(0).Attribute("goals").Value

'' If homeTeamScor = "?" Then
'' homeTeamScor = "0"
'' End If
'' If awayTeamScor = "?" Then
'' awayTeamScor = "0"
'' End If
'' homeTeamScore = CInt(homeTeamScor)
'' awayTeamScore = CInt(awayTeamScor)
'' End If

'' If match.Descendants("events").Elements.Count > 0 Then

'' End If


这篇关于将xml子节点读取到我的sql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 22:08