 




<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The VBScript Network and Systems Administrator&#039;s Cafe &#187; XML</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator</link>
	<description></description>
	<lastBuildDate>Tue, 11 Oct 2011 18:36:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>A great XMLDOM online reference for creating XSLT Translation documents</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/a-great-xmldom-online-reference-for-creating-xslt-translation-documents/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/a-great-xmldom-online-reference-for-creating-xslt-translation-documents/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 22:54:09 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[Online References]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLDOM]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/?p=102</guid>
		<description><![CDATA[If you were interested in my previous posts relating to XML and XSL Translations. You&#8217;ll know how difficult it is sometimes to get the syntax right and know what functions are available to you when writing a XSLT document to translate a XML file into HTML. Well, I recently found a great reference for XML&#8217;s [...]]]></description>
				<content:encoded><![CDATA[<p>If you were interested in my previous posts relating to XML and XSL Translations. You&#8217;ll know how difficult it is sometimes to get the syntax right and know what functions are available to you when writing a XSLT document to translate a XML file into HTML.</p>
<p>Well, I recently found a great reference for XML&#8217;s <a href="http://www.devguru.com/Technologies/xmldom/quickref/xmldom_objects.html" target="_blank">XMLDOM interface</a>. Check it out,</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/a-great-xmldom-online-reference-for-creating-xslt-translation-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to retrieve HTML web pages with VBScript via the Microsoft.XmlHttp object</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/how-to-retrieve-html-web-pages-with-vbscript-via-the-microsoftxmlhttp-object/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/how-to-retrieve-html-web-pages-with-vbscript-via-the-microsoftxmlhttp-object/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 15:00:05 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Microsoft.XmlHttp]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript Objects]]></category>
		<category><![CDATA[Web Pages]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/how-to-retrieve-html-web-pages-with-vbscript-via-the-microsoftxmlhttp-object/</guid>
		<description><![CDATA[Recently, I had a situation where I had to pull down a HTML page to compare it to a known copy of the page. Certainly, IE or FireFox&#8211; or Google&#8217;s Chrome would have done the trick and I could have viewed the source. But that would require me to do work every time we needed to [...]]]></description>
				<content:encoded><![CDATA[<p><font color="#0000ff"><font color="#000000">Recently, I had a situation where I had to pull down a HTML page to compare it to a known copy of the page. Certainly, IE or FireFox&#8211; or Google&#8217;s Chrome would have done the trick and I could have viewed the source. But that would require me to do work every time we needed to check the page against the known good source.</font></font></p>
<p><font color="#0000ff"><font color="#000000"> Instead I wrote a script to pull the HTML source and echo the response to the console (or a messag box if you are not using cscript to execute the script). While not a full blown HTTP QA script it does do the job of getting the HTTP responses from the server and is certainly a core part of any QA script anyone would write.</font></font></p>
<p>Basically the script uses the Microsoft.XMLHTTP object to preform all the HTTP calls and retrieve the HTML page. It sounds scary, but if you look at the script below I think you&#8217;ll find that it really is quite easy to accomplish<font color="#0000ff"><font color="#000000">.  So, here is the script&#8217;s code:</font></font></p>
<p><font color="#0000ff">URL=&#8221;</font><a href="http://www.gamersigs.net/"><font color="#0000ff">http://www.gamersigs.net/</font></a><font color="#0000ff">&#8220;<br />
</font><font color="#0000ff">Set WshShell = WScript.CreateObject(&#8220;WScript.Shell&#8221;)<br />
</font><font color="#0000ff">Set http = CreateObject(&#8220;Microsoft.XmlHttp&#8221;)</font></p>
<p><font color="#0000ff">On Error Resume Next<br />
http.open &#8220;GET&#8221;, URL, False<br />
http.send &#8220;&#8221;<br />
if err.Number = 0 Then<br />
     WScript.Echo http.responseText<br />
Else<br />
     Wscript.Echo &#8220;error &#8221; &amp; Err.Number &amp; &#8220;: &#8221; &amp; Err.Description<br />
End If<br />
set WshShell = Nothing<br />
Set http = Nothing<br />
</font></p>
<p><font color="#0000ff"><font color="#000000">Enjoy!</font></font></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/how-to-retrieve-html-web-pages-with-vbscript-via-the-microsoftxmlhttp-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Document group policy objects in Microsoft Word using VBScript</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/document-group-policy-objects-in-microsoft-word-using-vbscript/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/document-group-policy-objects-in-microsoft-word-using-vbscript/#comments</comments>
		<pubDate>Fri, 02 May 2008 16:15:42 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[DataManagement]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Microsoft.XMLDOM]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Word.application]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easily-document-group-policy-objects-in-microsoft-word-using-vbscript-with-the-microsoftxmldom-and-wordapplication-objects/</guid>
		<description><![CDATA[OK, here is the posting I hinted at in my previous posting this week entitled, Using VBScript to create Word documents automatically with the Word.Application Object. In that posting I mentioned a project where I had to create a ton of documentation&#8230; but I didn&#8217;t say what it was that I had to document. Yeah, [...]]]></description>
				<content:encoded><![CDATA[<p>OK, here is the posting I hinted at in  my previous posting this week entitled, <a title="Permanent Link to Using Vbscript to create Word documents automatically with the Word.Application Object" rel="bookmark" href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/using-vbscript-to-create-word-documents-automatically-with-the-wordapplication-object/">Using VBScript to create Word documents automatically with the Word.Application Object</a>. In that posting I mentioned a project where I had to create a ton of documentation&#8230; but I didn&#8217;t say what it was that I had to document. Yeah, you guessed it from this article&#8217;s title&#8230; <strong><em>Group Policy Settings!</em></strong> I had to document settings in a series of policies I was proposing we implement at my employer. Here is the scenario:</p>
<p>I was asked &#8220;Can you document all the settings you are proposing in the new policies for the other members of IT? Also, Can you document the name of the setting, what you want it to be and what options are available to change it to? Oh, and what each value means when you set it?&#8230;. Do you think you&#8217;ll have time to also let us know for each setting what the supported or intended OS version is for the setting? I need it by Friday.&#8221;</p>
<p>Now, much like you might do, I said &#8220;I&#8217;ll try.&#8221; and mumbled under my breath later &#8220;If you bring me a pound of Lead I&#8217;ll turn it to Gold too!&#8221;&#8230; None the less, after my initial pity party, I began looking at the Information available to me in the Group Policy Management Console (Available <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0A6D4C24-8CBD-4B35-9272-DD3CBFC81887&amp;displaylang=en" target="_blank">here</a> if you don&#8217;t have it already.), much to my surprise I found almost everything I needed when I looked at the individual settings&#8230; it just wasn&#8217;t in a format I could show to people or they could read easily. So I set out to try and copy and paste the information into word&#8230; for 20 seconds&#8230; and realized this is way to much work! And what do I always say??????   <strong>Be Lazy!</strong></p>
<p>Now I looked at the options available to me on exporting the file and CSV was one of them, but unfortunately all the relationships were lost and I couldn&#8217;t make heads or tails of how to cobble it back together in a meaningful way after the export. Then I noticed XML and remembered my last post on Microsoft.XMLDOM (<a title="Permanent Link to Using XML in vbscript via Microsoft.XMLDOM to work with data feeds" rel="bookmark" href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/using-xml-in-vbscript-via-microsoftxmldom-to-work-with-data-feeds/">Using XML in VBScript via Microsoft.XMLDOM to work with data feeds</a>) and thought, I really need to get back to that&#8230; so here we are!</p>
<p>First, Just like my last post&#8211; you&#8217;ll need Microsoft Word installed where you run this script for it to operate. Then you&#8217;ll need to use The Group Policy Management console to export the policy settings to XML. (hover over the icons along the top, it&#8217;s the one with the icon that looks like a page of paper with an arrow pointing right, one of the save as options is XML.) Save this file into the location where the script is located (I recommend a descriptive name, because it will be the heading for your document.) and with a single edit of the script you will have a word doc on the root of your C: drive with the same name&#8212; only documented in Word!</p>
<p>The script basically opens and reads in the XML Document and creates a Word.Application object to create a Microsoft Word Document at the root of the C: Drive, then writes formatted text to the document to make the data in the XML readable. But, enough of a introduction! On to the script! Here is the script:</p>
<p><span style="color: #0000ff"> set xmlDoc=CreateObject(&#8220;Microsoft.XMLDOM&#8221;)<br />
Set objWord = CreateObject(&#8220;Word.Application&#8221;)<br />
Set objDoc = objWord.Documents.Add()<br />
Set objSelection = objWord.Selection</span></p>
<p><span style="color: #0000ff">&#8216;This is the actual name of the XML document minus the path and the &#8220;.XML&#8221; extension, it becomes the word doc header</span><br />
<span style="color: #0000ff">xmlfile = &#8220;Locked Down Desktop Policy&#8221;</span></p>
<p><span style="color: #0000ff">objSelection.Font.Name = &#8220;Arial&#8221;<br />
objSelection.Font.Size = &#8220;18&#8243;<br />
objSelection.Font.Bold = True<br />
objSelection.TypeText xmlfile &amp; VbCrLf</span></p>
<p><span style="color: #0000ff">objSelection.Font.Bold = False<br />
objSelection.Font.Size = &#8220;10&#8243;</span></p>
<p><span style="color: #0000ff">xmlDoc.async=&#8221;false&#8221;<br />
xmlDoc.load(xmlfile &amp;&#8221;.xml&#8221;)<br />
for each x in xmlDoc.documentElement.childNodes<br />
If x.nodename = &#8220;Computer&#8221; or x.nodename = &#8220;User&#8221; Then<br />
For Each y In x.childnodes<br />
if y.Nodename = &#8220;ExtensionData&#8221; then<br />
For Each z In y.childnodes<br />
If z.Nodename = &#8220;Extension&#8221; Then<br />
For Each setting In z.childnodes<br />
objSelection.TypeText &#8220;______________________________________&#8221; &amp; vbCr<br />
DocumentPolicy(Setting)<br />
Next<br />
End if<br />
Next<br />
End if<br />
Next<br />
End If<br />
Next<br />
objDoc.SaveAs(&#8220;C:\&#8221; &amp; xmlfile &amp; &#8220;.doc&#8221;)<br />
objWord.Quit</span><br />
<span style="color: #0000ff">Function DocumentPolicy(Setting)<br />
</span><span style="color: #0000ff">&#8216;this function basically cleans up the headers of the word document, so they are more human readable<br />
Select Case setting.nodename<br />
Case &#8220;q1:Policy&#8221;<br />
replacestr = &#8220;q1:&#8221;<br />
Case &#8220;q1:DropDownList&#8221;<br />
replacestr = &#8220;q1:&#8221;<br />
Case &#8220;q1:Name&#8221;<br />
replacestr = &#8220;q1:&#8221;<br />
Case &#8220;q1:Value&#8221;<br />
replacestr = &#8220;q1:&#8221;<br />
Case &#8220;q1:State&#8221;<br />
replacestr = &#8220;q1:&#8221;<br />
Case &#8220;q2:Audit&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:SecurityOptions&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:EventLog&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:RestrictedGroups&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:File&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:Display&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q3:General&#8221;<br />
replacestr = &#8220;q3:&#8221;<br />
Case &#8220;q3:HashRule&#8221;<br />
replacestr = &#8220;q3:&#8221;<br />
Case &#8220;q3:PathRule&#8221;<br />
replacestr = &#8220;q3:&#8221;<br />
Case &#8220;q3:InternetZoneRule&#8221;<br />
replacestr = &#8220;q3:&#8221;<br />
Case &#8220;q4:AutoEnrollmentSettings&#8221;<br />
replacestr = &#8220;q4:&#8221;<br />
Case &#8220;q4:AutoEnrollmentSettings&#8221;<br />
replacestr = &#8220;q4:&#8221;<br />
Case &#8220;q4:RootCertificateSettings&#8221;<br />
replacestr = &#8220;q4:&#8221;<br />
Case &#8220;q4:EFSSettings&#8221;<br />
replacestr = &#8220;q4:&#8221;<br />
Case &#8220;q5:PreferenceMode&#8221;<br />
replacestr = &#8220;q5:&#8221;<br />
Case &#8220;q2:PreferenceMode&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:ProxySettings&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:UseSameProxy:&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:HTTP:&#8221;<br />
replacestr = &#8220;q2:&#8221;<br />
Case &#8220;q2:NoProxyIntranet:&#8221;<br />
replacestr = &#8220;q2:&#8221;</span><span style="color: #0000ff">End Select<br />
objSelection.Font.Bold = True<br />
objSelection.TypeText VbCrLf &amp; replace(setting.nodename, replacestr,&#8221;") &amp; VbCrLf<br />
objSelection.Font.Bold = False<br />
For Each Value In Setting.Childnodes<br />
NodeName = replace(Value.nodename,replacestr,&#8221;")<br />
If NodeName = &#8220;Explain&#8221; Then<br />
objSelection.Font.Bold = True<br />
objSelection.TypeText Nodename &amp; &#8220;: &#8221; &amp; vbcrlf<br />
objSelection.Font.Bold = False<br />
objSelection.TypeText vbTab &amp; replace(value.text,&#8221;\n\n&#8221;, VbCrLf &amp; VbCrLf &amp; vbTab )&amp; vbcrlf<br />
Else<br />
objSelection.Font.Bold = True<br />
objSelection.TypeText Nodename &amp; &#8220;: &#8221;<br />
objSelection.Font.Bold = False<br />
objSelection.TypeText vbtab &amp; value.text &amp; vbcrlf<br />
End if<br />
Next<br />
If isnull(Setting.childnodes) Then<br />
For Each node In Setting.childnodes<br />
DocumentPolicy(node)<br />
next<br />
End if<br />
objSelection.TypeText VbCrLf</span><span style="color: #0000ff"><span style="color: #0000ff">End Function</span></span><span style="color: #0000ff">Now, when you run this script agains your export there may be some XML tags I didn&#8217;t notice because a setting you set is one I didn&#8217;t set. Any time you see them in the document you can add a new <strong>Case</strong> statement in the select case followed by setting the <em>replacestr</em> to the string you want to replace with a null. The lines I&#8217;m talking about look similar to this:</span></p>
<p><span style="color: #0000ff"> </span></p>
<p><span style="color: #0000ff"> Case &#8220;q2:xxxxxxxx&#8221;<br />
replacestr = &#8220;q2:&#8221;</span></p>
<p><span style="color: #0000ff"><span style="color: #000000">As always, this code works perfectly. However, sometimes the formatting of the blog breaks the code if you copy and paste it into your editor. So, if you’d like to not type or troubleshoot any syntax errors due to the copy and paste problems– I’ve provided the code for download, plus example output files  from my final tests for you. You’ll find the code and other files available for download from my website’s (<a href="http://www.websystemsadministration.com/">www.websystemsadministration.com</a>) File Depot under the <span style="color: #0000ff"><em>ITKE Blog Scripts</em></span> category.<span style="color: #0000ff"> </span><span style="color: #0000ff"><span style="color: #0000ff"><span style="color: #000000">Enjoy and happy scripting!</span></span></span></span></span></p>
<p>&lt;!&#8211;a href=&#8221;http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/pinging-a-remote-computer-from-another-remote-computer-using-the-wmi-win32_pingstatus-class/trackback/&#8221; title=&#8221;Trackback URL&#8221;&gt;Trackback URL&#8211;&gt;</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/document-group-policy-objects-in-microsoft-word-using-vbscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explanation: Using Microsoft.XMLDOM to work with data feeds in VBScript</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/explanation-using-microsoftxmldom-to-work-with-data-feeds-in-vbscript/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/explanation-using-microsoftxmldom-to-work-with-data-feeds-in-vbscript/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 17:39:54 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[360voice]]></category>
		<category><![CDATA[DataManagement]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Microsoft.XMLDOM]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/explaination-using-microsoftxmldom-to-work-with-data-feeds-in-vbscript/</guid>
		<description><![CDATA[You may recall we recently worked with a cool little script that itself didn&#8217;t have anything to do with systems administration, the 360voice API script in a previous post, but the concepts can be used in many different areas since XML data feeds are ever becoming the standard way to communicate related data between applications [...]]]></description>
				<content:encoded><![CDATA[<p>You may recall we recently worked with a cool little script that itself didn&#8217;t have anything to do with systems administration, the <a href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/using-xml-in-vbscript-via-microsoftxmldom-to-work-with-data-feeds/">360voice API script</a> in a previous post, but the concepts can be used in many different areas since XML data feeds are ever becoming the standard way to communicate related data between applications and systems.</p>
<p>In this script, I used many topics we&#8217;ve previously discussed and added a powerful object, <a href="http://msdn2.microsoft.com/en-us/library/aa468547.aspx">Microsoft.XMLDOM</a>. Essentially, DOM stands for Document Object Model&#8211; which is a way for the document to describe and relate the data it contains. Here is an example XML document header for &#8220;mydata&#8221;</p>
<p><font color="#0000ff">&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;!DOCTYPE Mydata SYSTEM &#8220;mydata.dtd&#8221;&gt;<br />
</font></p>
<p><font color="#0000ff"><font color="#000000">This essentially in the first line tells us the file is an XML document, Version 1.0 to be specific, and in the second line tells us the Document Type Definition file that we can have the parser verify the XML file against. DTD&#8217;s and XML Schemas are beyond the scope of what we&#8217;re discussing but can be very useful becasue they define the rules by which a XML document must conform to be considered valid&#8211; however they are not required to be in an XML file.</font></font></p>
<p><font color="#0000ff"><font color="#000000">After these lines the XML file has nodes and child nodes in it. This is where the bulk of our work was done going through the nodes and pulling out child nodes and values. In this illustration we&#8217;ll use the following URL to <a href="http://www.360voice.com/api/score-getlist.asp?tag=jlees&amp;num=2">my XML Game data</a> at <a href="http://www.360voice.com">360voice.com</a> (note the data will change over time, but the datastructure should stay pretty much the same) </font></font></p>
<p><font color="#0000ff"><font color="#000000">As of this moment, the file looks like:</font></font></p>
<p class="e"><span class="m"><font color="#0000ff">&lt;?</font></span><span class="pi"><font color="#0000ff">xml version=&#8221;1.0&#8243; encoding=&#8221;ISO-8859-1&#8243; </font></span><span class="m"><font color="#0000ff">?&gt;</font></span></p>
<p class="e"><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">api</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">info</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">version</font></font></span><span class="m"><font color="#0000ff">&gt;</font></span><span class="tx"><font color="#0000ff"><strong>1.2</strong></font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">version</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">gamertag</font></font></span><span class="m"><font color="#0000ff">&gt;</font></span><span class="tx"><font color="#0000ff"><strong>jlees</strong></font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">gamertag</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">info</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">gamerscore</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">score</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">value</font></font></span><span class="m"><font color="#0000ff">&gt;</font></span><span class="tx"><font color="#0000ff"><strong>23740</strong></font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">value</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">date</font></font></span><span class="m"><font color="#0000ff">&gt;</font></span><span class="tx"><font color="#0000ff"><strong>3/20/2008 4:42:02 AM</strong></font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">date</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">score</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">score</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">value</font></font></span><span class="m"><font color="#0000ff">&gt;</font></span><span class="tx"><font color="#0000ff"><strong>23740</strong></font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">value</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"></span><span class="m"><font color="#0000ff">&lt;</font></span><span class="t"><font color="#0000ff"><font color="#990000">date</font></font></span><span class="m"><font color="#0000ff">&gt;</font></span><span class="tx"><font color="#0000ff"><strong>3/19/2008 4:45:18 AM</strong></font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">date</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">score</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">gamerscore</font></font></span><span class="m"><font color="#0000ff">&gt;<br />
</font></span><span class="m"><font color="#0000ff">&lt;/</font></span><span class="t"><font color="#0000ff"><font color="#990000">api</font></font></span><span class="m"><font color="#0000ff">&gt;</font></span></p>
<p class="e"><span class="m"></span></p>
<p class="e"><span class="m"><font color="#0000ff"><font color="#000000">Notice how the main Node (The <em>&#8220;document&#8221;</em> Node) is titled <span class="t"><font color="#990000">api</font></span>? The XML Parser automatically read that entire node in at the load of the document. After that we have nodes called <span class="t"><font color="#990000">info </font></span>and <span class="t"><font color="#990000">gamerscore</font></span> that both contain data and/or child nodes. </font></font></span></p>
<p class="e"><span class="m"><font color="#0000ff"><font color="#000000">the info tag contains the version and gamertag values, you&#8217;ll notice I used the gamertag value in the script to pull the name of the gamertag with this line of the script code after checking to see if the currently looped through tag had the name &#8220;info&#8221;:</font></font></span></p>
<p class="e"><span class="m"><font color="#0000ff"><font color="#3366ff">WScript.Echo GetTagValue(x,”gamertag”)</font><br />
</font></span><span class="m"></span></p>
<p class="e"><span class="m"><font color="#0000ff"><font color="#000000">See how that works? This example was pretty simple since it was just off the root. The score value and date were a bit harder to get at, but not to bad.</font></font></span></p>
<p class="e"><span class="m"><font color="#0000ff"><font color="#000000">They are contained in a child node called &#8220;score&#8221;, but they are a child of gamerscore&#8211; so you&#8217;ll see that I check to see if the tag is &#8220;gamerscore&#8221; and then loop through the score tag separately looking for each instance of the node called score and pulling the tag value and placing it into an array called <em>gamerscore.</em> </font></font></span></p>
<p class="e"><span class="m"></span><span class="m"><font color="#0000ff"><font color="#000000">All pretty straightforward. There are certainly better ways to deal with XML than writing code tightly around the XML itself, but this illustrates the use of Microsoft.XMLDOM and explains the heirarchial nature of XML nicely the way it&#8217;s been coded.</font></font></span></p>
<p class="e"><span class="m"><font color="#0000ff"><font color="#000000">See if you can play around with the code and make it better! Thanks again to the folks at 360voice for providing the API and it&#8217;s documentation!</font></font></span></p>
<p class="e"><span class="m"><font color="#0000ff"><font color="#000000">Happy coding and have fun!</font></font></span></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/explanation-using-microsoftxmldom-to-work-with-data-feeds-in-vbscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using XML in vbscript via Microsoft.XMLDOM to work with data feeds</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/using-xml-in-vbscript-via-microsoftxmldom-to-work-with-data-feeds/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/using-xml-in-vbscript-via-microsoftxmldom-to-work-with-data-feeds/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 17:57:22 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[360voice]]></category>
		<category><![CDATA[DataManagement]]></category>
		<category><![CDATA[Microsoft.XMLDOM]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/using-xml-in-vbscript-via-microsoftxmldom-to-work-with-data-feeds/</guid>
		<description><![CDATA[In this installment I wanted to both celebrate and congratulate the winners of the ITKE Challenge that has been running over the last few months for an XBOX 360 ELITE system, among other prizes. I also wanted to write about XML use in vbscript as well so the challenge was how to accomplish both tasks… [...]]]></description>
				<content:encoded><![CDATA[<p><span style="font-family: Times New Roman">In this installment I wanted to both celebrate and congratulate the winners of the ITKE Challenge that has been running over the last few months for an XBOX 360 ELITE system, among other prizes. I also wanted to write about XML use in vbscript as well so the challenge was how to accomplish both tasks…</span></p>
<p class="MsoNormal"><span style="font-family: Times New Roman">Then I remembered a great community site, that I’ve been a member of for a little over a year or so, called </span><a href="http://www.360voice.com/"><span style="color: #800080;font-family: Times New Roman">360voice</span></a><span style="font-family: Times New Roman">. Basically, those guys have a truly awesome idea over there… I play games with my Xbox 360 and it blogs about the times we have—and I don’t have to do any work on my own. <img src='http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  If you have a 360 and don’t have an account setup, go over and check it out, tell ‘em </span><a href="http://www.360voice.com/tag/JLees"><span style="color: #800080;font-family: Times New Roman">Jlees</span></a><span style="font-family: Times New Roman"> sent you. Heck, while you are at it watch my blog there and drop me a note.</span></p>
<p><span style="font-family: Times New Roman">At any rate, one of my challenges was to get everyone the same XML file, while not creating it myself because I wanted the script to be useful under certain circumstances. 360voice came through with their </span><a href="http://www.360voice.com/forum/topic.asp?TOPIC_ID=3"><span style="color: #800080;font-family: Times New Roman">API Documentation</span></a><span style="font-family: Times New Roman">! Think about it… now your scripting life has insite into your gaming life (and other’s as well) you could write a script to compare your achievements to your buddies, show the games you haven’t completed, and all sorts of other stuff. Why?? Because you can!</span></p>
<p><span style="font-family: Times New Roman">Consider this working code (that indecently pulls the XML directly from the website without saving it locally) that shows the last 10 days of gamerscore history for two gamertags in the output, in my case I chose mine, Jlees, and one of the owners of the site, changeagent, to do the comparison.. From this script alone you could graph your gamerscore and a buddies so you can compare and have irrefutable bragging rights about your gaming powers! <strong>(notice:</strong> that I put just about everything together we’ve talked about up to now in this one script, if your just joining us you might want to go back and brush up the last few weeks worth of blogs really quick. Also, I&#8217;ve noticed some cases where the sourcecode does not copy correctly, so I have uploaded the source to this article to my website <a href="http://www.websystemsadministration.com/blogfiles/360voice.zip">here</a> for you to download.<strong>)</strong></span></p>
<p><span style="color: #3366ff;font-family: Times New Roman">Option Explicit</span></p>
<p class="MsoNormal"><span style="color: #3366ff;font-family: Times New Roman">Dim GamerTag1,GamerTag2, GamerScore, Days, xmlDoc, x, y, Value, Count</span></p>
<p class="MsoNormal"><span style="font-family: Times New Roman"><span style="color: #3366ff">GamerTag1 = &#8220;CrashSerious&#8221; &#8216;change this to your gamertag<br />
GamerTag2 = &#8220;ChangeAgent&#8221; &#8216;change this to your buddies gamer tag<br />
&#8216; a quick note on the following line. It&#8217;s great the folks at </span><a href="http://www.360voice.com/"><span style="color: #3366ff">www.360voice.com</span></a><span style="color: #3366ff"> gave us this API<br />
&#8216; While you likely can change this to something other than 10 below, I strongly encourage you To<br />
&#8216; limit it to less than a month. The pulling of this data will no doubt have an impact on their servers<br />
&#8216; and excessive pulls will likely get you blocked, the API removed, or restricted.<br />
&#8216; Basically, be a good neighbor.<br />
Days = 10 &#8216; change this to the number of days to pull.</span></span></p>
<p class="MsoNormal"><span style="color: #3366ff;font-family: Times New Roman">DisplayTagHistory(GamerTag1)<br />
DisplayTagHistory(GamerTag2)</span></p>
<div></div>
<p><span style="font-family: Times New Roman"></p>
<p class="MsoNormal"><span style="color: #3366ff">Sub DisplayTagHistory(GamerTag)<br />
 set xmlDoc=CreateObject(&#8220;Microsoft.XMLDOM&#8221;)</span></p>
<p class="MsoNormal"><span style="color: #3366ff"> ReDim GamerScore(Days)</span></p>
<p class="MsoNormal"><span style="color: #3366ff"> xmlDoc.async=&#8221;false&#8221;<br />
 xmlDoc.load(&#8220;</span><a href="http://www.360voice.com/api/score-getlist.asp?tag"><span style="color: #3366ff">http://www.360voice.com/api/score-getlist.asp?tag</span></a><span style="color: #3366ff">=&#8221; &amp; GamerTag &amp; &#8220;&amp;num=&#8221; &amp; days)<br />
 for Each x in xmlDoc.documentElement.childNodes<br />
   If x.nodename = &#8220;info&#8221; Then &#8216; this is where the gamer tag is located in the node named &#8220;gamertag&#8221;<br />
    WScript.Echo GetTagValue(x,&#8221;gamertag&#8221;)<br />
   End If<br />
 <br />
   If x.NodeName = &#8220;gamerscore&#8221; Then<br />
  Count = 0<br />
  For Each y In x.childnodes  &#8217; this is where the score for that day is located<br />
         &#8217; in a node named &#8220;value&#8221;<br />
   GamerScore(Count) = GetTagValue(y,&#8221;value&#8221;)<br />
   &#8217;below we output the data. You could easily change the &#8220;vbTab &amp; &#8220;:&#8221; &amp; vbTab&#8221; to<br />
   &#8217;a , and create a CSV or write to a file. the world&#8217;s wide open from here.<br />
   WScript.Echo Date-Count &amp; vbTab &amp; &#8220;:&#8221; &amp; vbTab &amp; Gamertag &amp; vbTab &amp; &#8220;: &#8221; &amp; GamerScore(Count)<br />
   Count = Count + 1<br />
  Next<br />
   End If<br />
 Next<br />
End sub</span></p>
<p class="MsoNormal"><span style="color: #3366ff">&#8216;note this function assumes only one node named the same as SrchStr is in the XMLTAG child node.<br />
&#8216; if there is more than one, only the last value will be returned.<br />
Function GetTagValue(XMLTag, SrchStr)<br />
 for each Value In XMLTag.childNodes<br />
    if ucase(Value.nodename) = Ucase(SrchStr) Then<br />
     GetTagValue = Value.text &#8216;get the value in the node requested.<br />
    End If<br />
 Next <br />
End Function</span></p>
<p><span style="font-family: Times New Roman">The output, with the script untouched, should look like so:</span></p>
<p><span style="font-family: Times New Roman"><span style="color: #008000"> JLees<br />
3/14/2008 : JLees : 23740<br />
3/13/2008 : JLees : 23730<br />
3/12/2008 : JLees : 23730<br />
3/11/2008 : JLees : 23730<br />
3/10/2008 : JLees : 23730<br />
3/9/2008 : JLees : 23730<br />
3/8/2008 : JLees : 23700<br />
3/7/2008 : JLees : 23700<br />
3/6/2008 : JLees : 23700<br />
3/5/2008 : JLees : 23700<br />
ChangeAgent<br />
3/14/2008 : ChangeAgent : 12817<br />
3/13/2008 : ChangeAgent : 12817<br />
3/12/2008 : ChangeAgent : 12817<br />
3/11/2008 : ChangeAgent : 12817<br />
3/10/2008 : ChangeAgent : 12817<br />
3/9/2008 : ChangeAgent : 12817<br />
3/8/2008 : ChangeAgent : 12817<br />
3/7/2008 : ChangeAgent : 12817<br />
3/6/2008 : ChangeAgent : 12817<br />
3/5/2008 : ChangeAgent : 12777</span></span></p>
<p><span style="font-family: Times New Roman">I only used ONE new thing in this code <em><a href="http://www.adp-gmbh.ch/web/js/msxmldom/methods_properties.html"><span style="color: #800080">Microsoft.XMLDOM</span></a></em>, which we’ll discuss in a later entry but I wanted to call your attention to the following line in this entry:</span></p>
<p><span><span style="color: #0000ff;font-family: Times New Roman">xmlDoc.load(&#8220;http://www.360voice.com/api/score-getlist.asp?tag=&#8221; &amp; GamerTag &amp; &#8220;&amp;num=&#8221; &amp; days)</span></span><span style="font-family: Times New Roman"> </span></p>
<p> </p>
<p></span></p>
<p class="MsoNormal"><span style="font-family: Times New Roman">This line is the one where you would specify the path for the XML file, whether it is a local file or a file on the internet—like this </span><a href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/feed/"><span style="color: #800080;font-family: Times New Roman">rss feed</span></a><span style="font-family: Times New Roman"> to my blog. Also note that the DisplayTagHistory subroutine is highly focused to <strong><em>this</em></strong> XML feed and will likely need some work to get it to display another.</span></p>
<p class="MsoNormal"><span style="font-family: Times New Roman">Enjoy!</span></p>
<p class="MsoNormal"><span style="font-family: Times New Roman"><strong><span style="color: #ff0000">Extra Credit:</span></strong> Can you modify the code to include the other owner of the 360voice site and compare his score with mine and changeagent&#8217;s? His Gamertag is <a href="http://www.360voice.com/tag/Fatty%20Chubs">Fatty Chubs</a>.</span></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/using-xml-in-vbscript-via-microsoftxmldom-to-work-with-data-feeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
