+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. 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>
    Quote Quote  

  2. VH Veteran jimmalenko's Avatar
    Join Date: Aug 2003
    Location: Down under
    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.
    Quote Quote  

  3. jimmalenko,

    Thank you much appreciated. It works great
    Quote Quote  

  4. jimmalenko,

    Just 1 more thing if you have time. How would i get the filepath to a variable?? See XML above.

    Thanks.
    Quote Quote  

  5. VH Veteran jimmalenko's Avatar
    Join Date: Aug 2003
    Location: Down under
    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 plot
    If in doubt, Google it.
    Quote Quote  

  6. Thanks,

    Using your method I can select anything from the xml.
    Quote Quote  

  7. VH Veteran jimmalenko's Avatar
    Join Date: Aug 2003
    Location: Down under
    Originally Posted by NYPlayer
    Thanks,

    Using your method I can select anything from the xml.
    Exactly
    If in doubt, Google it.
    Quote Quote  

  8. Member
    Join Date: Oct 2009
    Location: Germany
    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?
    Quote Quote  




Similar Threads

  1. Can VBscript/Batch read MPEG file?
    By Cazz in forum Programming
    Replies: 11
    Last Post: 3rd Sep 2010, 08:50
  2. Replies: 3
    Last Post: 18th Sep 2006, 04:16
  3. VBSCRIPT for WMVencoder need assistance
    By NYPlayer in forum Programming
    Replies: 2
    Last Post: 31st Jan 2006, 11:59
  4. reg.xml file needed?
    By t-dot in forum SVCD2DVD & VOB2MPG
    Replies: 3
    Last Post: 20th Jul 2005, 11:59
  5. assistance needed
    By rains81 in forum Newbie / General discussions
    Replies: 3
    Last Post: 4th Aug 2003, 12:30
About   Advertise   Forum   RSS Feeds   Statistics   Tools