I need some help parsing a XML file with a script. I would like to get just the description data and put it into "Plot" variable. I got it working somewhat but I cannot pull of just the description. It grabs the whole showlist. I tried using description as my node but it doesn't work.
See Script and xml sample below.
script
Dim objXML, Root, x
set objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = "false"
objXML.load("E:\sage2\DesperateHousewives-MyHeartBelongstoDaddy-404318-0.mpg.xml")
Set Root = objXML.documentElement
For Each x In Root.childNodes
if x.nodename="showList" then
plot=x.text
msgbox plot
end if
Next
xml sample
<?xml version="1.0" encoding="utf-8"?>
<sageShowInfo version="1.1">
<channelList>
<channel channelId="10334">
<channelName>KATU</channelName>
<channelDescription>KATU Portland, OR</channelDescription>
<channelNetwork>ABC Affiliate</channelNetwork>
<channelNumber>2</channelNumber>
</channel>
</channelList>
<favoriteList>
<favorite favoriteId="383397">
<title>Desperate Housewives</title>
<firstRun/>
<reRun/>
<autoDelete/>
</favorite>
</favoriteList>
<showList>
<show epgId="EP6723180028">
<title>Desperate Housewives</title>
<episode>My Heart Belongs to Daddy</episode>
<category>Drama</category>
<description>Gabrielle causes a prison riot while visiting Carlos; Lynette learns that Parker has an imaginary friend; Susan helps Mike search for Zach.</description>
<peopleList>
<person role="Actor">Teri Hatcher</person>
<person role="Actor">Felicity Huffman</person>
<person role="Actor">Marcia Cross</person>
<person role="Actor">Eva Longoria</person>
<person role="Actor">Nicolette Sheridan</person>
</peopleList>
<language>English</language>
<originalAirDate>2005-10-17T00:00:00.00Z</originalAirDate>
<airing sageDbId="404318" startTime="2006-07-10T04:00:00.00Z" duration="3600" channelId="10334" favoriteId="383397">
<parentalRating>TV14</parentalRating>
<ratings>
<rating>TV14</rating>
</ratings>
<extraDetails>Closed Captioned, Stereo, SAP</extraDetails>
<mediafile sageDbId="474807" type="TV" startTime="2006-07-10T04:00:00.70Z" duration="3599">
<segmentList>
<segment startTime="2006-07-10T04:00:00.70Z" duration="3599" filePath="E:\sage2\DesperateHousewives-MyHeartBelongstoDaddy-404318-0.mpg"/>
</segmentList>
</mediafile>
</airing>
</show>
</showList>
</sageShowInfo>
+ Reply to Thread
Results 1 to 8 of 8
Thread
-
Code:Dim xmlDoc, objNodeList, plot Set xmlDoc = CreateObject("Msxml2.DOMDocument") xmlDoc.load("c:\inetpub\wwwroot\test.xml") Set objNodeList = xmlDoc.getElementsByTagName("description") If objNodeList.length > 0 then For each x in objNodeList plot=x.Text msgbox plot Next Else msgbox chr(34) & "description" & chr(34) & " field not found." End If
Works for me
If in doubt, Google it.
jimmalenko,
Thank you much appreciated. It works great
jimmalenko,
Just 1 more thing if you have time. How would i get the filepath to a variable?? See XML above.
Thanks.
Here's code to get both plot and file Path and is more efficient than what I posted earlier:
Code:Dim description, filepath Set xmlDoc = CreateObject("Msxml2.DOMDocument") xmlDoc.load("c:\test.xml") Set ElemList = xmlDoc.getElementsByTagName("segment") filepath = ElemList.item(0).getAttribute("filePath") MsgBox filepath Set ElemList = xmlDoc.getElementsByTagName("description") plot = ElemList.item(0).Text MsgBox plotIf in doubt, Google it.
Thanks,
Using your method I can select anything from the xml.
ExactlyOriginally Posted by NYPlayer
If in doubt, Google it.
On this same topic I am trying to use VBScript to have a user enter in a Date, than use that date to be placed at the end of url to GET an XML file. Once I capture that XML file I would like to parse out data. I have the GET request working, but it is not getting the user input data and I am having trouble parsing the data.
For the parse I want to grab information like the one posted above, and place that data in another text file.
Can anyone help me out?
Similar Threads
-
Can VBscript/Batch read MPEG file?
By Cazz in forum ProgrammingReplies: 11Last Post: 3rd Sep 2010, 07:50 -
WMV to FLV assistance needed
By OM2 in forum Newbie / General discussionsReplies: 0Last Post: 10th Jan 2010, 06:45 -
region code assistance needed with the sony ns-700h dvd player
By stressed_with_sony in forum DVD RippingReplies: 1Last Post: 2nd Jun 2009, 00:53 -
region code assistance needed for the sony dvp ns700h
By stressed_with_sony in forum DVD RippingReplies: 0Last Post: 1st Jun 2009, 20:34 -
Assistance needed converting to WMV for playback on Xbox 360
By eggedd2k in forum Video ConversionReplies: 2Last Post: 16th May 2007, 17:29
StatisticsNewest guidesLatest tool updatesNew media comments



Quote