有将RSS新闻的XML转入Access数据库的工具吗?

nakhi 2005-08-24 09:06:09
我对数据库的访问比较熟悉。想对订阅的多个新闻网站的RSS进行分析,但是直接对XML操作有点费劲,不知道是否有这样的控件或是工具。可以将多个RSS的XML直接导入ACCESS数据库。因为这些RSS的格式都是一样的,即发布时间,标题,摘要。

这是一个懒惰的问题,多谢!
...全文
64 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
malingxian 2005-08-25
  • 打赏
  • 举报
回复
1.根据XML架构建立Access数据表。
2.将XML读入Dataset.
3.将Dataset写入Access数据库。

后面是一个读写XML的类:
Public Class XML
Private _FileName As String

Public Property FileName() As String
Get
Return _FileName
End Get
Set(ByVal Value As String)
_FileName = Value
End Set
End Property

Public Sub New(ByVal FileName As String)
_FileName = FileName
End Sub

Public shared Function ExistFile(byval filename as string) As Boolean
Return System.IO.File.Exists(filename)
End Function

'从XML中读取数据集
Public Function Read() As DataSet
If Not ExistFile() Then
Throw New Exception("XML文件:" & _FileName & " 不存在!")
Return Nothing
End If
Dim tmpXMLRead As System.IO.FileStream
Dim tmpXMLReader As System.Xml.XmlTextReader
Try
tmpXMLRead = New System.IO.FileStream(_FileName, System.IO.FileMode.Open, IO.FileAccess.Read)
tmpXMLReader = New System.Xml.XmlTextReader(tmpXMLRead)
Dim tmpDataset As New DataSet("XML File")
tmpDataset.ReadXml(tmpXMLReader)
tmpXMLReader.Close()
tmpXMLRead.Close()
Return tmpDataset
Catch ex As Exception
If Not tmpXMLReader Is Nothing Then tmpXMLReader.Close()
If Not tmpXMLRead Is Nothing Then tmpXMLRead.Close()
Throw ex
End Try
End Function

'写数据集到XML中
Public Sub Write(ByVal XMLDataSet As DataSet)
If XMLDataSet Is Nothing Then Throw New Exception("源数据流不存在!")
Dim tmpXMLWrite As System.IO.FileStream
Dim tmpXMLWriter As System.Xml.XmlTextWriter
Try
tmpXMLWrite = New System.IO.FileStream(_FileName, System.IO.FileMode.Create)
tmpXMLWriter = New System.Xml.XmlTextWriter(tmpXMLWrite, System.Text.UTF8Encoding.UTF8)
tmpXMLWriter.Namespaces = True
tmpXMLWriter.Formatting = System.Xml.Formatting.Indented
tmpXMLWriter.IndentChar = vbTab

tmpXMLWriter.WriteStartDocument() '书写版本为“1.0”的 XML 声明。
XMLDataSet.WriteXml(tmpXMLWriter, XmlWriteMode.WriteSchema)
tmpXMLWriter.Close()
tmpXMLWrite.Close()
Catch ex As Exception
If Not tmpXMLWrite Is Nothing Then tmpXMLWrite.Close()
If Not tmpXMLWriter Is Nothing Then tmpXMLWriter.Close()
Throw ex
End Try
End Sub
End Class

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧