Her følger den funktion der søger for at generere xml'en og uploade den til vores interne googleserver:
Public Function Upload() As Boolean
Dim xmlSource As String
xmlSource = ""
xmlSource = "<?xml version=¤1.0¤ encoding=¤UTF-8¤ ?>" & _
"<!DOCTYPE gsafeed PUBLIC ¤-//Google//DTD GSA Feeds//EN¤ ¤¤>" & _
"<gsafeed>" & _
"<header>" & _
"<datasource>mpi_feed</datasource>" & _
"<feedtype>full</feedtype>" & _
"</header>" & _
"<group>"
Dim curURL As Variant
'// mvarURLS indeholde X antal URL'er som skal indekseres
For Each curURL In mvarURLS
xmlSource = xmlSource & "<record url=¤" & CStr(curURL) & "¤ action=¤add¤ mimetype=¤text/html¤>" & _
"<content>" & _
"<![CDATA[" & _
"<html><body><h1>Overskrift</h1>Hu hej hvor det går</body></html>" & _
"]]>" & _
"</content>" & _
"</record>"
Next
xmlSource = xmlSource & "</group>"
xmlSource = xmlSource & "</gsafeed>"
xmlSource = Replace(xmlSource, "¤", Chr(34))
Dim curFeedGate As Variant
Dim poster As MSXML2.XMLHTTP
Set poster = New MSXML2.XMLHTTP
'// mvarFeedGates indeholder X antal url'er til en given google feed gate - f.eks
http://100.120.10.1:19900/xmlfeed For Each curFeedGate In mvarFeedGates
curFeedGate = curFeedGate & "?feedtype=full&datasource=mpi_feed&data=" & URLEncode(xmlSource)
poster.open "POST", CStr(curFeedGate), False, "jbsearchadmin", "fes10val"
poster.send xmlSource
Debug.Print poster.Status & " : " & poster.statusText
Next
Dim returnValue As Boolean
returnValue = True
ExitPoint:
Upload = returnValue
Exit Function
ErrorHandler:
returnValue = False
Resume ExitPoint
End Function