Bohack

Check In and Tune Out!
 
 
« How To Find Out Where Someone Lives by Their Phone Number
T1 RJ-48C Wiring and the Smart Jack »

Query and Parse XML from VBScript



Toying around I needed to query XML from VBScript and parse it out for only the elements I needed. So I wrote a VBScript and figured I would share it. Many posts out there just load a file rather than a URL, this script will do both and I simplified it a bit.

The script here will basically query the URL and parse it our for the element name of description. Find a sitemap for a site and change the URL line like (http://somewhere.com/gsitemap.xml) and then change the xmltag to “loc”.

url = "http://news.google.com/news?hl=en&tab=wn&ned=us&q=test&ie=UTF-8&nolr=1&output=rss"
xmltag = "description"

set xmlDoc = createobject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.load (url)

set xmlCol = xmldoc.getElementsByTagName(xmltag)

For Each Elem In xmlCol
 wscript.Echo(Elem.firstChild.nodeValue)
Next

WScript.Echo "XML Element Count :" & xmlCol.length

Set xmlCol = Nothing
Set xmlDoc = Nothing

Tags: VBScript

This entry was posted on Saturday, February 14th, 2009 at 2:19 pm and is filed under Scripts.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.

One Response to “Query and Parse XML from VBScript”

  1. rb Says:
    February 7th, 2012 at 3:06 am

    really helpful! thanks a ton! 🙂

  • Channels

    • Beer (2)
    • Blog (1)
    • Exchange (2)
    • Ham Radio (1)
    • Homebrew (3)
    • Linux / Unix (4)
    • Misc (1)
    • Mods (4)
    • Networking (1)
    • Programming (4)
    • Recipes (2)
    • Scripts (7)
    • Security (1)
    • Software (2)
    • Spam (1)
    • Telco (7)
    • Virtual PC (1)
    • VMware (3)
    • VOIP (3)
    • Windows (16)
    • Windows 2008 (4)
    • Windows 7 (5)
  • Archives

    • September 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • November 2011
    • September 2011
    • July 2011
    • April 2011
    • February 2011
    • January 2011
    • October 2010
    • August 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • June 2009
    • May 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
  • Links

    • Blogarama Blogarama – The Blog Directory
    • BlogHub Blog Directory
    • Blogrankings Technology Blogs – Blog Rankings
    • Blogville.us blogville.us
    • Buzzerhut free directory | buzzerhut.com
    • Ontoplist Online Marketing
    • Primechoiceautoparts Discount Auto Parts
    • PTC My Employer
 

  Copyright - Bohack 2025 ©