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

Print This Post Print This Post

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
Bookmark and Share

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.
You can leave a response, or trackback from your own site.

Leave a Reply





  • Author

    • About Bohack
    • Contact Info
  • Channels

    • Blog (1)
    • Exchange (2)
    • Ham Radio (1)
    • Homebrew (2)
    • Linux / Unix (2)
    • Mods (2)
    • Programming (3)
    • Recipes (2)
    • Scripts (5)
    • Spam (1)
    • Telco (3)
    • Virtual PC (1)
    • VMware (2)
    • Windows (11)
  • Archives

    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • June 2009
    • May 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
  • Misc

    • More Links
 

 

Copyright - Bohack 2009i