I am trying to write a simple VBScript that looks into an XML file, pulls out two attributes, adds them, and the result to an output file. So far I have been able to load the XML input file using:
Option Explicit
Set objDoc = CreateObject("MSXML.DOMDocument")
objDoc.Load "C:\_STATS_SCRIPTS\STATS_HOME.xml"
Then I created and initialized variables like this:
Dim fumlost
Dim intercept
Dim turnovers
fumlost="0"
intercept="0"
turnovers="0"
Here is what my XML looks like (truncated after the totals subtree):
<fbgame source="Tas Football" version="4.16.01" generated="9/3/2014">
<venue gameid="01UA-WVU" visid="WVU" homeid="UA" visname="West Virginia" homename="Alabama" date="8/30/2014" location="Atlanta, Georgia" stadium="Georgia Dome" start="3:36" end="7:05" neutralgame="Y" duration="3:29" attend="70502" temp="" wind="" weather="Indoor">
<officials ref="David Epperly" ump="Mike Webster" line="Steve Clein" lj="Rod Pearson" bj="Pat Ryan" fj="Mike Culler" sj="Eddie Bonet"></officials>
<notes>
<note text="Replay: Dan Post"></note>
</notes>
<rules qtrs="4" mins="15" downs="4" yds="10" kospot="35" tbspot="20" kotbspot="25" patspot="3" safspot="20" td="6" fg="3" pat="1" patx="2" saf="2" defpat="2" rouge="1" field="100" toh="3" sackrush="Y" fgaplay="Y" netpunttb="Y"></rules>
</venue>
<team vh="H" code="8" id="UA" name="Alabama" record="1-0" abb="A">
<linescore prds="4" line="3,17,10,3" score="33">
<lineprd prd="1" score="3"></lineprd>
<lineprd prd="2" score="17"></lineprd>
<lineprd prd="3" score="10"></lineprd>
<lineprd prd="4" score="3"></lineprd>
</linescore>
<totals totoff_plays="82" totoff_yards="538" totoff_avg="6.6">
<firstdowns no="30" rush="13" pass="14" penalty="3"></firstdowns>
<penalties no="7" yds="49"></penalties>
<conversions thirdconv="9" thirdatt="15" fourthconv="0" fourthatt="1"></conversions>
<fumbles no="0" lost="0"></fumbles>
<misc yds="0" top="37:47" ona="0" onm="0" ptsto="0"></misc>
<redzone att="4" scores="4" points="24" tdrush="3" tdpass="0" fgmade="1" endfga="0" enddowns="0" endint="0" endfumb="0" endhalf="0" endgame="0"></redzone>
<rush att="49" yds="288" gain="294" loss="6" td="3" long="26"></rush>
<pass comp="24" att="33" int="1" yds="250" td="0" long="38" sacks="0" sackyds="0"></pass>
<rcv no="24" yds="250" td="0" long="38"></rcv>
<punt no="2" yds="101" long="62" blkd="0" tb="0" fc="1" plus50="1" inside20="1" avg="50.5"></punt>
<ko no="7" yds="453" ob="0" tb="3"></ko>
<fg made="4" att="4" long="47" blkd="0"></fg>
<pat kickatt="3" kickmade="3"></pat>
<defense tackua="34" tacka="38" tot_tack="72" tflua="6" tfla="0" tflyds="30" sacks="3" sackyds="25" brup="3"></defense>
<kr no="4" yds="99" td="0" long="26"></kr>
<pr no="1" yds="-1" td="0" long="0"></pr>
<scoring td="3" fg="4" patkick="3"></scoring>
</totals>
What I need to do next is assign /fbgame/team/totals/fumbles@lost to my fumbles variable, assign /fbgame/team/totals/pass@int to my intercept variable, and then add the two together to make turnovers, then output. I think I can handle the summing of variables and outputting a file, but I'm lost on how to get the XML attribute assigned to my variables. Earlier I successfully made a script that uses sXPath to split visiting team and home team out of my main input file, but I am currently unable to use what I learned there to get this task done!
I am very appreciative of any help that comes my way, as I am a n00b scripter and in a little over my head!