Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Creating a XML Document

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Creating a XML Document
  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 >>
 Creating a XML Document - 1/24/2007 3:14:53 AM   
  ignignokt

 

Posts: 31
Score: 0
Joined: 9/12/2006
Status: offline
I am writing a script that will create a simple visual database in XML.  I was originally going to create an XML document manually by just outputting to a file but realized that everytime the script runs, that it would ultimately append the document incorrectly. I am now  looking into "Microsoft.XMLDOM" option of creating a XML doc.

I ultimately need to create a XML document that can have "discs" appended to it and keep the previous  XML intact. I couldnt find basic syntax of how to populate the tags.  I was wondering if anyone could point me in the right direction.

Ultimately I would like to create the following:

quote:


<catalog>
  <disc>
      <title>DVD 1</title>
          <file>
              <name>video1.avi</name>
              <size>1.456 KB</size>
              <created>01/25/1999</created>
              <image1>vid1-1.jpg</image1>
              <image2>vid1-2.jpg</image2>
                <image3>vid1-3.jpg</image3>
              <image4>vid1-4.jpg</image4>
              <image5>vid1-5.jpg</image5>
              <image6>vid1-6.jpg</image6>
          </file>
  </disc>
</catalog>


< Message edited by ignignokt -- 1/24/2007 3:16:39 AM >
 
 
Post #: 1
 
 RE: Creating a XML Document - 1/24/2007 3:16:45 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Devguru.com has a really good reference on the XMLDOM and all of the sample code is VBScript.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ignignokt)
 
 
Post #: 2
 
 RE: Creating a XML Document - 1/24/2007 4:10:35 AM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Great reference  

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Creating a XML Document - 1/24/2007 4:39:18 AM   
  ignignokt

 

Posts: 31
Score: 0
Joined: 9/12/2006
Status: offline
Thanks for the link.  I checked out the site but only found examples where the XML file is present.  I would like to create an XML file from scratch.

(in reply to dm_4ever)
 
 
Post #: 4
 
 RE: Creating a XML Document - 1/24/2007 4:42:30 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
I thought that you were going to be appending to an existing xml and that was your concern?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ignignokt)
 
 
Post #: 5
 
 RE: Creating a XML Document - 1/24/2007 4:49:15 AM   
  ignignokt

 

Posts: 31
Score: 0
Joined: 9/12/2006
Status: offline
Ultimately yes, but I need to create one to begin with.

Lets say I have 10 CDs with video clips on them.  Well I want to put in the first CD, named Vids 1, and the script will look at every video file on that CD and take screenshots of them and put them in a folder on the hard drive.  Well I want to use XML to list all the CDs, the files that are on that cd, and file info like size, date create, and the screenshots for each file. 

So I will need to create the XML because it doesnt exist, but then I want to append it from there.  Once I have the CD, "Vids 1" on there, ill do the same thing for the CD "Vids 2" and etc.

Should I just manually create a XML file and just have the script append it that way?

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: Creating a XML Document - 1/24/2007 5:05:21 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
To be honest with you there wouldn't be much difference between just writing one out and making if via the XMLDOM.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ignignokt)
 
 
Post #: 7
 
 RE: Creating a XML Document - 1/24/2007 5:31:52 AM   
  ignignokt

 

Posts: 31
Score: 0
Joined: 9/12/2006
Status: offline
I tried using a sample from DevGuru to test it out on a manually made XML file and its compling and running but no changes are being made to the file:

code:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("C:\videocatalog\vid.xml")
Dim objCurrNode, objNewNode, objNewText
Set objNewNode = objXMLDoc.createElement("title")
Set objNewText = objXMLDoc.createTextNode("AVI 2")
objNewNode.appendChild(objNewText)
Set objCurrNode = objXMLDoc.documentElement
objCurrNode.appendChild(objNewNode)
Set objCurrNode = objCurrNode.lastChild

file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<disc>
<title>AVI 1</title>
</disc>
</catalog>

(in reply to ebgreen)
 
 
Post #: 8
 
 RE: Creating a XML Document - 1/24/2007 5:33:01 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
you have to save the file (.Save) after you make the changes.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ignignokt)
 
 
Post #: 9
 
 RE: Creating a XML Document - 1/24/2007 5:40:22 AM   
  ignignokt

 

Posts: 31
Score: 0
Joined: 9/12/2006
Status: offline
Actually, im closer to getting what I want to do, but had another request for help.

My XML file is in the wrong format:
quote:

  
<catalog><disc></disc><title>AVI 2</title></catalog>


It should be:
quote:

 
<catalog><disc><title>AVI 2</title></disc></catalog>


Here's my code so far:

      



< Message edited by ignignokt -- 1/24/2007 6:54:48 AM >

(in reply to ebgreen)
 
 
Post #: 10
 
 RE: Creating a XML Document - 1/24/2007 7:28:58 AM   
  ignignokt

 

Posts: 31
Score: 0
Joined: 9/12/2006
Status: offline
anyone have a clue?

(in reply to ignignokt)
 
 
Post #: 11
 
 RE: Creating a XML Document - 1/24/2007 10:03:11 AM   
  TNO


Posts: 1397
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Heres the stupid simple guide that taught me XML:

http://msconline.maconstate.edu/Tutorials/XML/

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to ignignokt)
 
 
Post #: 12
 
 RE: Creating a XML Document - 1/24/2007 1:22:19 PM   
  dm_4ever


Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Since this is new to me I thought I'd give it a shot. The following code provided these results:  BTW, thanks for the link TNO.

<catalog>
<disc><title>AVI 2</title></disc>
</catalog>


      

< Message edited by dm_4ever -- 1/24/2007 1:30:52 PM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TNO)
 
 
Post #: 13
 
 RE: Creating a XML Document - 1/25/2007 1:03:43 AM   
  ignignokt

 

Posts: 31
Score: 0
Joined: 9/12/2006
Status: offline
Works great. Thanks for your help.

(in reply to dm_4ever)
 
 
Post #: 14
 
 
 
  

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 >> Creating a XML Document 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