Windows Scripting
  Home arrow Windows Scripting arrow Reading XML Files in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Reading XML Files in WSH
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-12-01

    Table of Contents:
  • Reading XML Files in WSH
  • Getting started
  • More advanced queries
  • Further filtering results
  • Constructing advanced queries
  • What to do when it doesn’t work

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Reading XML Files in WSH


    (Page 1 of 6 )

    In my last article I showed you how you can use Microsoft’s XML Parser to create XML documents in WSH. Today I’m going to show you how to use your scripts to read information from XML files.

    You’re going to need a copy of the XML file that you created in my last article. If you don’t have one, you can download an example XML file here. This is a sample XSPF audio playlist. XSPF is an XML-based playlist specification designed to be easily portable and cross-platform compatible.

    <?xml version="1.0" encoding="UTF-8"?>

    <playlist version="1" xmlns="http://xspf.org/ns/0/">

       <trackList>

           <track>

              <location>http://www.nilpo.com/pub/tracks/Breaking%20Benjamin%20-%20The%20Diary%20of%20Jane.mp3</location>

              <title>The Diary Of Jane</title>

              <creator>Breaking Benjamin</creator>

              <info>http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=171774391&id=171774379&s=143441</info>

              <album>Phobia</album>

              <trackNum>2</trackNum>

           </track>

           <track>

              <location>http://www.nilpo.com/pub/tracks/The%20Rising%20-%20Who%20You%20Are.mp3</location>

              <title>Who You Are</title>

              <creator>The Rising</creator>

              <info>http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=275505564&id=275505471&s=143441</info>

              <album>Future Unknown</album>

              <trackNum>10</trackNum>

           </track>

       </trackList>

    </playlist>

    Its structure is relatively simple. A playlist element houses a track listing that contains each of the tracks in the playlist. Each track has its own set of elements that contain properties about that track.

    Remember that XML files are simple database structures. So it’s best to think of an XML file as you would a database. That mentality will make this a little easier to understand for most system administrators, so that’s the approach I’ll be taking in this article. As you will soon see, with the help of the XML Parser, an XML file becomes far more than a simple text file. It actually allows us to create queries for returning specific information—and that sounds more like a database to me!

    More Windows Scripting Articles
    More By Nilpo


     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek