Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VBScript to write files to xml

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,28119
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBScript to write files to xml
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 VBScript to write files to xml - 11/18/2005 1:41:23 AM   
  ptaz

 

Posts: 13
Score: 0
Joined: 11/18/2005
Status: offline
Hi,

Am new to vbscript and would like example or code to write file names to an xml file. e.g.

I have a folder with x amount of files (i.e. sampleaug05.pdf, exampleSept05, etc.)  I would like to have a script that will take the new files and append them to an xml file in the following format.

<documents>
<document>
 <docuemntname>Corporate</docuemntname>
 <year>2005</year>
 <month>January</month>
 <url>documents/samplejan05.pdf</url>
 <name>Download</name>
</document>
<document>
 <docuemntname>Finance</docuemntname>
 <year>2004</year>
 <month>January</month>
 <url>documents/samplejan05.pdf</url>
 <name>Download</name>
</document>
</documents>

Can anyone help??? please

Thanks
 
 
Post #: 1
 
 RE: VBScript to write files to xml - 11/18/2005 3:04:02 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Here's something to get you started. I don't know how you will be entering in all of the information into the XML (where the information is stored) so I set this up to pull the information from a text file.

      

Here's the text file information I used to store the information that will be pulled into the script. Be sure to save as "XML_Variables.txt"

Chicago;2004;January;documents/samplejan04.pdf;downloads/samplejan05.pdf
New York;2003;March;documents/samplemar03.pdf;downloads/samplemar03.pdf


More information can be found out at: http://www.w3schools.com/xml/default.asp
You will also want to look into the XSL so that you can display your XML better

(in reply to ptaz)
 
 
Post #: 2
 
 RE: VBScript to write files to xml - 11/20/2005 8:49:27 PM   
  ptaz

 

Posts: 13
Score: 0
Joined: 11/18/2005
Status: offline
Thanks. But I was mor looking at a script that would get the modified date and time and then append that to my existing xml file.

I have a folder with the X.pdf files.  I would like only the files taht have been modified to be added.

Would this be possible, and if so how.

(in reply to Country73)
 
 
Post #: 3
 
 RE: VBScript to write files to xml - 11/23/2005 12:56:39 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Is this what you are looking for, or something similar to it?
This will look in the folder you specifiy (wherever your pdf's are stored) and look for files that have been modified in the last 5 days. For the files that have been modified in that time frame it will get the FileName, Year & Month it was modified, you will need to supply the URL and Download site
and write all of that to the XML.

      

(in reply to ptaz)
 
 
Post #: 4
 
 RE: VBScript to write files to xml - 11/23/2005 8:23:21 PM   
  ptaz

 

Posts: 13
Score: 0
Joined: 11/18/2005
Status: offline
Yes it is sort off Thank you.

How do I get the actual Filename to be inserted.  (For example.  File.Name will give you the name corp_aug_05.pdf, corp1_sept_o5.pdf) Using the script you created.  So if the file is corp_aug_05 it would display Corporate, for corp1 it would display Corporate One, etc.  Hence just taking the first few string in the filename.

For Each File In myFolder.Files
FileLast = File.DateCreated
FileMod = DateDiff("d", FileLast, Now)
    If FileMod < 5 Then
 Corporate = File.Name ' I would like the filename to appear here.
 myDate = Split(FileLast,"/")
 myYear = Left(myDate(2),4)
 myMonth = myDate(0)
 myURL = "documents/" & Corporate
 Download = "Download"
 Call pstrXML(Corporate,myYear,myMonth,myURL,Download)

< Message edited by ptaz -- 11/24/2005 1:10:40 AM >

(in reply to Country73)
 
 
Post #: 5
 
 RE: VBScript to write files to xml - 11/24/2005 2:16:10 AM   
  ptaz

 

Posts: 13
Score: 0
Joined: 11/18/2005
Status: offline
It ok.  I got it working.  I was not putting quotes round the wor I was looking for.  Thanks for all your help Country73.

(in reply to ptaz)
 
 
Post #: 6
 
 RE: VBScript to write files to xml - 11/30/2005 12:06:43 AM   
  ptaz

 

Posts: 13
Score: 0
Joined: 11/18/2005
Status: offline
Hi Me again.

Is there a way to do the smae thing but using server side sciprting?  If so what would I need to change in my script?

(in reply to Country73)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBScript to write files to xml Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts