ҡդӶ ʵŧ 纺촨շ٨絴͵ ᷹ФѺ

͵Դҷҧ Inbox Ѻ

˹ѡ
-
VB 6/VB.Net
ASP/ASP.Net
Ѻ¤
¹ҹ Flash Movie
ռͺش  
 RSS Feeds
 ǹŴ RSS Reader ...   Download  RSS Reader

Forum - www.g2gnet.com
Webmaster - www.g2gnet.com
Visitors - Session views
 5 6 1 6 1 7 7

7 ѹҤ ..2549
133 Users On-Line.
Visitors - Page views
 8 9 7 3 9 2 0
1 Ҿѹ ..2551

Google   
g2gnet.com
Ҵѡ:  

¹ XML Ѻ Visual Basic 6.0 Ҥ 3 (ŧҧ XML HTML)

Category »  VB 6/VB.Net
: Webmaster 22/6/2551 10:58:00
(ҹ : 33477) 
á֡Ѵ͡ HTML ҧѹҴ vi editor 躹кԺѵԡ Unix Notepad MS Windows ͹Ѻ ÷͡ҹ͡ ѹͧҨҡҡҹͧ͡ HTML ԧ 蹡 TAG 㹷ءѹͧͷ㹡÷¢ ҧ DreamWeaver ˹鹵ͧ TAG Ҫ ѹѺ˹ҵ ˹觷ҧ觵ҧŧ ѹ͡Ѻ ... չѺ͡ XML (eXtensive Markup Language) ѹշɮ XML Ҥµ䫵ҧҡ ҹҡ͡Ѻ () Тǹ зйҸѺѹ йӷҧͧҤԺѵ ѹѺͧ ( ... µѧա ... 55555+)
Basic Diagram
ѧ Diagram ͧ ѹǤԴẺҹ (ա) ... 觷оٴ¡Ѻ Ф¡ѹ੾ѡɳ ٻẺͧ͡ XML ҹ ... ҧʹ͹ ͧ VB6.0 Programmer ҧⴴǴ (ǡ) ѧöӧҹѺ XML ФѺ

Ѻżҹҧ͡ XML
зӡŧ XML HTML MS Visual Basic 6


¹ XML Ѻ Visual Basic 6.0 Ҥ 1
¹ XML Ѻ Visual Basic 6.0 Ҥ 2
鹡кǹ÷ӧҹ

Project --> References ...
͡ XML 4.0 ẺҧФѺ ... ͧ


Project --> Components ...


Design Time


Run Time
ǡҧẺ ѧ䧪ѹ͹Ѻ IE Browser ԧСѹ

ٻẺҵðҹͧ͡ XML Ѻ÷ RSS Feed

Ӥѭ  çѹѺ ٻẺͧŢ ҧ Ѻ Ѻ
<?xml version="1.0" encoding="Windows-874" ?> 
  <rss version="2.0">
    <channel>
      <title>    ͵  - www.g2gnet.com</title> 
      <link>http://www.g2gnet.com/News/</link> 
      <language>th-TH</language> 
      <copyright>Copyright @ 2006 www.g2gnet.com</copyright> 

ٻẺ Тͧ
<item>
    <title>Ǩͺá鹤Ѻ੾еŢ (VB.Net)</title> 
    <link>http://www.g2gnet.com/News/activenews_view.asp?articleID=106</link>
    <description><![CDATA[ ͧ VB6 Ǣ .NET СһҴ ...]]></description>
    <pubDate>15/6/2551 16:39:00</pubDate> 
</item>
 ... 
<item>
    <title>ûѺöҹ Mouse Wheel Ѻ MS Visual Basic 6 IDE</title> 
    <link>http://www.g2gnet.com/News/activenews_view.asp?articleID=105</link>
    <description><![CDATA[ Mouse Wheel  ҵ١駡çҧ ...]]></description>
    <pubDate>14/6/2551 1:11:00</pubDate> 
</item>
...
...
 ... ǻԴ Tag  
    </channel>
  </rss>

ѧ Node ͧ Item ... ж١è (<TR>) ͧҧ (<TABLE>) ... Ѻ͡ HTML
ӤѡѺ HTML Tag ͧ

´ͧ HTML Tag ҧҧӹǹ 1 3 ѡ

ŧҧ XML HTML

ҧӹǹ (ӹǹ) § 1 ѡҹ鹹ФѺ
<table width=100% border=0 cellpadding=3 cellspacing=0 bordercolor=#000000>
<tr>    <--- 
<td>   <--- ѡ
<a href='http://www.g2gnet.com/News/activenews_view.asp?articleID=106' target='_self'>
Ǩͺá鹤Ѻ੾еŢ (VB.Net)</a><br>
ͧ VB6 Ǣ .NET СһҴ ...
15/6/2551 16:39:00
</td>    <--- Դѡ
</tr>    <--- Դ
 (TR)
<tr>    <--- 
<td>   <--- ѡ
<a href='http://www.g2gnet.com/News/activenews_view.asp?articleID=105' target='_self'>
ûѺöҹ Mouse Wheel Ѻ MS Visual Basic 6 IDE</a><br>
<b>Mouse Wheel</b>  ҵ١駡çҧФѺͧ ...
14/6/2551 1:11:00
</td>    <--- Դѡ
</tr>    <--- Դ
...
...
 ... ǻԴ Tag  
</table>
ǹŴ Source Code Ѻ MS Visual Basic 6.0 - Service Pack 6
 ǹŴ Visual Basic 6.0 SP5: Run-Time Redistribution Pack
 ǹŴ Microsoft Data Access Object (MDAC) Jet 4.0 Update
 ǹŴ Microsoft Visual Basic Service Pack 6

Option Explicit

Private Sub ConvertXML(strURL As String)
' strURL ͡˹˹觢ͧ XML 
' strURL = "http://www.rssthai.com/rss/it.xml"
'  ASP/PHP Script öҹҡҹҧ XML ͡ҡ ... ѹ UpToDate
' strURL = "http://www.g2gnet.com/news/rss.asp"
' ҡ͡ѺԹ öͧҹͧ¹ФѺ  ...
' strURL = "http://localhost/ XML"

' ҹͧ DOM (Document Object Model) Component
'  Component ǹ лСͺ仴
' Nodes - IXMLDOMNode
' NodeLists - IXMLDOMNodeList
' Elements - IXMLDOMElement
' Attributes - IXMLDOMattribute
Dim xmlDom As New MSXML2.DOMDocument40
Dim nodeCol, oNode, oChildNode


Set xmlDom = New MSXML2.DOMDocument40

' 駤ҤسѵѺ͡ (Run Time)
xmlDom.async = False
xmlDom.validateOnParse = False
xmlDom.resolveExternals = False

' 鹡÷ӧҹҹ Remote Server
xmlDom.setProperty "ServerHTTPRequest", True

' ˹͡û·ҧҹ
xmlDom.Load (strURL)

' Ѻ纤 Tag ͧ HTML 
Dim strTag As String
'  Link ˹ҷ
Dim strLink As Boolean
' ǹͧ Title (Ǣ͢)
Dim strTitle As String
' ѹͧ
Dim strPubdate As String
' ´ͧ
Dim strDescription As String

    ' 鹡ŧҧ XML  HTML
    ' ͺ͹͡÷ѺٻẺ XML  (ѡɳТͧѺǹФѺ)
    If Not xmlDom.documentElement Is Nothing Then
        Set nodeCol = xmlDom.documentElement.selectNodes("channel/item")
        
        ' 鹡ҧ Tag ¼ҧ (Table) 繵ǤҢ÷
        ' öҹ/¹ HTML Tag ... ºѺ ...
        strTag = strTag & ("<table width=100% border=0 cellpadding=3 cellspacing=0 bordercolor=#000000>")
        
        '  Element
        ' ǧͺͧ FOR  ҧ 1  (TR)  1 ѡ (TD) ͧҧ (TABLE) ФѺ
        For Each oNode In nodeCol
            '  <tr>  ѡ <td> Ѻ HTML Tag
            strTag = strTag & ("<tr><td>")
            strTag = strTag & ("<div align='left'>" & vbCrLf)
            
            ' ͺ¡ Link 
            Set oChildNode = oNode.selectSingleNode("link")
            If Not oChildNode Is Nothing Then
                ' ҡͧԴ Browser ˹
                'strTag = strTag & ("<a href='" & oChildNode.Text & "' target='_blank'>")
                
                ' Դ Browser ˹ͧѹ
                ' ѧԴ Tag ǹ еͧ÷駤Ѻ Title
                strTag = strTag & ("<a href='" & oChildNode.Text & "' target='_self'>")
                strLink = True
            Else
                strLink = False
            End If
            
            ' ͧ  (Title)
            Set oChildNode = oNode.selectSingleNode("title")
            If Not oChildNode Is Nothing Then
                strTitle = oChildNode.Text
                strTitle = Replace(strTitle, "&apos;", "'")
                strTitle = Replace(strTitle, "&", "&")
                strTitle = Replace(strTitle, vbCrLf, "<br>")
                strTag = strTag & ("" & strTitle & "")
            End If
            
            ' ҡ Link
            If strLink = True Then
                ' Դ Link  tag </a>
                strTag = strTag & ("</a><br>" & vbCrLf)
            End If
            
            ' ´ͧ (Description)
            Set oChildNode = oNode.selectSingleNode("description")
            If Not oChildNode Is Nothing Then
                strDescription = oChildNode.Text
                strDescription = Replace(strDescription, "![CDATA[", "'")
                strDescription = Replace(strDescription, "]]", "'")
                strDescription = Replace(strDescription, vbCrLf, "<br>")
                strTag = strTag & ("" & strDescription & "")
            End If
            
            ' ѹ (PubDate)
            Set oChildNode = oNode.selectSingleNode("pubDate")
            If Not oChildNode Is Nothing Then
                strPubdate = oChildNode.Text
                strPubdate = Replace(strPubdate, "&apos;", "'")
                strPubdate = Replace(strPubdate, "&", "&")
                strPubdate = Replace(strPubdate, vbCrLf, "<br>")
                strTag = strTag & ("" & strPubdate & "</div></td></tr>" & vbCrLf)
            End If
            
            ' ҹ ǡѹѺ ... 
            
        Next
        ' Դҧ Tag </table>
        strTag = strTag & ("</table>")
    End If
    
    '  HTML Tag  ... (ѹ Text ФѺ)
    ' ӡèѺѴ ... RSSFeed.html ... ͹ѹ֡Ż
    '  HTML Tag ѹ Text File ... ٻẺҵðҹ㹵ѹ͹Դٵ Browser ҧ
    Open App.Path & "\RSSFeed.html" For Output As #1
    Print #1, strTag
    Close #1
    
    '  Web Browser ͧ (webXML) 价˹ RSSFeed.html
    webXML.Navigate App.Path & ("\RSSFeed.html")
    
    ' ҡ˹Ẻس͡ XML Ẻ¤Ѻ (⫴ͧ ... )
    'webXML.Navigate strURL

End Sub

Private Sub cboAddress_KeyPress(KeyAscii As Integer)
    If Trim(cboAddress.Text) = "" Or Len(Trim$(cboAddress.Text)) = 0 Then Exit Sub
    If KeyAscii = vbKeyReturn Then
        cboAddress.AddItem cboAddress.Text
        Call ConvertXML(cboAddress.Text)
    End If
End Sub

Private Sub Form_Load()
    Me.Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
    
    ' صԵҧǡѹ 
    ' ͺ ѧ鹡سҾ鹵鹴 http:// ͹ú¹ФѺ
    cboAddress.Text = "http://www.g2gnet.com/News/rss.asp"
    
    '  XMLTest.xml ͺẺ Off Line Ѻ ... ҡ  ͧ Server 
    'cboAddress.Text = App.Path & "\XMLTest.xml"
    
    ' ˹˹纷ҧ͹Ѻ ...  ...
    ' ׹ Web Browser ͧѺѹЪ ״ЫԤѺ ... Ẻͺ 55555+
    webXML.Navigate App.Path & "\Blank.html"
End Sub
Ѻҧ
ҹ͡ XML ҡ Server ( LAN Internet) ѧͧ١ (Client) 仵ͧ¡Ѻ Connection 㹡͡Ѻ觰ҹŵҧ MSSQL, Oracle MYSQL ... ҧѹͨеҧöӧҹŵǹ ...
    Ҵٵҧͨй֡͡Ҩйҹô ...
  • Ẻ ӡҹǷ¡ RSS Feed Reader ... ҧФѺͧ
  • к¹ ͹ ASP/PHP Script Ẻͺ XML ѧͧ١ ... Application 繵ǨѴ᷹ ...
    1. ͧ¹ŴẺͺ (Update Ẻͺҹҧ䫵ҧ ... 礹ѹǧͺ )
    2. óչͷͺдѺͧǼ¹Ѻ Ӣͺ On Line ТѺͧ ...
    3. ¹ Win Application ͤǺѹ¡ҡ÷Ӽҹ Web Application ... 55555+
  • 繷 ON Line ... ѹл繺͹价ѹ ˹¡Ѻ仴 Ѻ IE ѹ Ѻ FireFox Ѻ ... ͧ Sniff URL ʶҹյҧʹ˹¹ФѺ (ͧ 3/5/7/9 ... RTSP Protocol ѧ rtsp://202.43.34.236/3 ... Ţ 3 ¹仵Ţͧ¤Ѻ (Ѻ Windows Media Player )
  • ͡ §ҹ ... ͹ѧ֡͡ ... 55555+

͵ - g2gNet Dot Com
Ţ¹ҳԪ硷͹ԡ 0407314800231
CopyLeft © 2004 - 2099 g2gNet.Com All rights reserved.
Email: [email protected] . 08-6862-6560