Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Extracting a value from an XML file

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Extracting a value from an XML file
  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 >>
 Extracting a value from an XML file - 6/21/2005 1:03:03 AM   
  dscannell

 

Posts: 16
Score: 0
Joined: 6/8/2005
From:
Status: offline
All I have a situation where I need to extract a value from an XML file and store to a variable to use later in the script the XML file is as follows
<?xml version="1.0"?>
<PrinterList>
<Printer1>localhost</Printer1>
<Printer2>localhost</Printer2>
<Printer3>localhost</Printer3>
</PrinterList>

I would need to extract the value of Preinter2.

Any help would be great
 
 
Post #: 1
 
 Re: Extracting a value from an XML file - 6/21/2005 2:22:31 AM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
With the XMLDOM object you can do (almost) anything you want to do with XML documents.
Here you can find all methods, events and properties described.
Look specifically at the selectSingleNode method.

HTH

(in reply to dscannell)
 
 
Post #: 2
 
 Re: Extracting a value from an XML file - 6/21/2005 2:59:21 AM   
  dscannell

 

Posts: 16
Score: 0
Joined: 6/8/2005
From:
Status: offline
Thanks for the help I am quite new and not sure how to use the XML DOM Method (although I will look into it) However I got round this by using this line of code.

mid(strx, InStr(strX, ">") + 1, (instr(strx, "</") - instr(strx, ">"))-1)

Just incase anyone else needs to do something like this in the future

(in reply to dscannell)
 
 
Post #: 3
 
 Re: Extracting a value from an XML file - 6/21/2005 7:30:24 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
When I tested your line of code, it returned:

<PrinterList>
<Printer1>localhost

Not exactly what you were asking for...


I made a small example script how to use the XMLDOM object:
      (don't forget to change the path of the XML file)

HTH

(in reply to dscannell)
 
 
Post #: 4
 
 Re: Extracting a value from an XML file - 6/22/2005 4:08:58 AM   
  dscannell

 

Posts: 16
Score: 0
Joined: 6/8/2005
From:
Status: offline
Thank You that helps a lot

(in reply to dscannell)
 
 
Post #: 5
 
 
 
  

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 >> Extracting a value from an XML file 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