![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Script to extract XML data Hi This script below connects to a weather RSS feed, what I would like to do is extract the text value for each <title> element within the <item> element and assign it a variable. I would also like to get the <url> text within <image> as a variable too. I got as far below as displaying the entire document.Element data but I'm not sure how to traverse through and pick up the field text I require - can anyone help ? Thanks JT Set objXML=CreateObject("MSXML2.DOMDocument") Set objXSL=CreateObject("MSXML2.DOMDocument") objXML.async=False objXSL.async=False objXML.setProperty "ServerHTTPRequest",true objXML.load ("http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/1181.xml") for each x in objXML.documentElement.childNodes Msgbox x.nodename Msgbox x.text next |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Script to extract XML data Try this: '****************************** Dim objXML, objXSL, x Set objXML = CreateObject("MSXML2.DOMDocument") Set objXSL = CreateObject("MSXML2.DOMDocument") objXML.async = False objXSL.async = False objXML.setProperty "ServerHTTPRequest", True objXML.Load "http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/1181.xml" objXML.setProperty "SelectionLanguage", "XPath" For Each x In objXML.documentElement.selectNodes(".//item/title") MsgBox x.nodename & " = " & x.Text Next For Each x In objXML.documentElement.selectNodes(".//image/url") MsgBox x.nodename & " = " & x.Text Next '****************************** Tim "JT" <JT@xxxxxx> wrote in message news:491b51dd$0$5709$9a6e19ea@xxxxxx Quote: > Hi > > This script below connects to a weather RSS feed, what I would like to do > is extract the text value for each <title> element within the <item> > element and assign it a variable. I would also like to get the <url> text > within <image> as a variable too. > > I got as far below as displaying the entire document.Element data but I'm > not sure how to traverse through and pick up the field text I require - > can anyone help ? > > Thanks > > JT > > > Set objXML=CreateObject("MSXML2.DOMDocument") > Set objXSL=CreateObject("MSXML2.DOMDocument") > objXML.async=False > objXSL.async=False > objXML.setProperty "ServerHTTPRequest",true > objXML.load > ("http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/1181.xml") > for each x in objXML.documentElement.childNodes > Msgbox x.nodename > Msgbox x.text > next |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Script to extract XML data That's great - thanks a lot! Tim Williams wrote: Quote: > Try this: > '****************************** > Dim objXML, objXSL, x > > Set objXML = CreateObject("MSXML2.DOMDocument") > Set objXSL = CreateObject("MSXML2.DOMDocument") > objXML.async = False > objXSL.async = False > objXML.setProperty "ServerHTTPRequest", True > objXML.Load "http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/1181.xml" > objXML.setProperty "SelectionLanguage", "XPath" > > For Each x In objXML.documentElement.selectNodes(".//item/title") > MsgBox x.nodename & " = " & x.Text > Next > > For Each x In objXML.documentElement.selectNodes(".//image/url") > MsgBox x.nodename & " = " & x.Text > Next > '****************************** > > Tim > > "JT" <JT@xxxxxx> wrote in message > news:491b51dd$0$5709$9a6e19ea@xxxxxx Quote: >> Hi >> >> This script below connects to a weather RSS feed, what I would like to do >> is extract the text value for each <title> element within the <item> >> element and assign it a variable. I would also like to get the <url> text >> within <image> as a variable too. >> >> I got as far below as displaying the entire document.Element data but I'm >> not sure how to traverse through and pick up the field text I require - >> can anyone help ? >> >> Thanks >> >> JT >> >> >> Set objXML=CreateObject("MSXML2.DOMDocument") >> Set objXSL=CreateObject("MSXML2.DOMDocument") >> objXML.async=False >> objXSL.async=False >> objXML.setProperty "ServerHTTPRequest",true >> objXML.load >> ("http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/1181.xml") >> for each x in objXML.documentElement.childNodes >> Msgbox x.nodename >> Msgbox x.text >> next > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| script to extract and create contacts | VB Script | |||
| batch job to extract data from tables in DB2 | .NET General | |||
| Powershell Script to extract drive information | PowerShell | |||
| Extract data from web page | PowerShell | |||
| Script to extract username from path statement | PowerShell | |||