Now when I try to save and apply the code I get an immediate errow on line 1--->
You have to take out the numbers (1. 2. 3. etc) that get copied with the script. Don't know why the forums copy numbers with the script; kinda defeats the purpose.
Don't forget to change the XML tags in this line to the ones you're stripping out:
parsecontent = extractInfo(getcontent,"<to>","</to>"&vbcrlf) '--retrieve unwanted section
Here's the code again without those numbers:
Dim xmlfile
xmlfile = object.Directory & "hi.xml" '--YOUR XML FILE HERE
'Called when the script is executed
Sub Object_OnScriptEnter
getcontent = readFile '--get xml contents
parsecontent = extractInfo(getcontent,"<to>","</to>"&vbcrlf) '--retrieve unwanted section
getcontent = replace(getcontent,parsecontent,"") '--erase unwanted section
writefile(getcontent)'--rewrite file
End Sub
'Declare constants
Const ForReading = 1, ForWriting = 2, ForAppending = 8
'Declare the file system object
Dim fso, f, Msg
Set fso = CreateObject("Scripting.FileSystemObject")
Function readFile
'Check if file exists
If fso.FileExists(xmlfile) Then
Set f = fso.OpenTextfile(xmlfile, ForReading)
fileinfo = f.readall
f.Close
Else
msgbox "File does not exist"
End If
readFile = fileinfo
End Function
Sub writeFile(newcontent)
'Create a file and write some text
Set f = fso.OpenTextfile(xmlfile, ForWriting, True)
f.Write newcontent
'Properly close file
f.Close
End Sub
Function extractInfo(info, startStr, endStr)
iStart = instr(1, info, startStr)
iEnd = instr(iStart, info, endStr)
iEnd = iEnd + Len(endStr) '--include closing tag
iLength = iEnd - iStart
info2 = mid(info, iStart, iLength)
extractInfo = info2
End Function
Question? Is there a way to get code for an XML weather formation like the picture I have and just use DESKtopX to retreve the Weather
data to a directory os choice then strip the bad stuff " Advertizing ", then set where the 42x42 Weather Images are at. the layout all the fields the same as the Samurize config, and just drop Samurize altogether and have the weather running with in the DesktopX Theme I have.
I'm inclined to say yes. If all the information present in the screenshot above is retreived from an XML file, you should be able to strip out the info you need and apply them to text objects or image objects. But without seeing the actual XML file you're using, I can only postulate on how to do that. If you can send or point me to an example XML file like the one you're using I might be able to tailor the code.
Here is the tutorial I read to get started on making rss readers -- LINK