NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 65 66 67 68 69 … 93 Next »
XMLTV parsing help needed

 
  • 0 Vote(s) - 0 Average
XMLTV parsing help needed
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#1
2005-10-27, 08:09 PM
I'm trying to parse my xmltv file to pull out the programme start/end times, channel id and title. I'm using an XPath query to get all the programmes as follows (apologies for it being VB.NET but it's much the same when done in C#)...

Code:
Dim GuideDoc As Xml.XmlDocument
Dim GuideNode, TempNode1, TempNode2 As Xml.XmlNode
Dim ProgrammeList, TitleList As Xml.XmlNodeList

GuideDoc = New Xml.XmlDocument
GuideDoc.Load(New Xml.XmlTextReader(New IO.StreamReader("C:\Program Files\XMLTV Radio Times\data.xml")))
GuideNode = GuideDoc.DocumentElement
ProgrammeList = GuideNode.SelectNodes("programme")
The problem is that each '<programme>' node actually has the timing and channel info in it as in...
Code:
<programme start="200510260915 +0100" stop="200510261000 +0100" channel="26">
But each XmlNode in ProgrammeList simply has an XmlNode.Name of 'programme'. for the life of me I can't find a way to get the rest of the data.

Is this possible or do I need to treat the XML file simply as flat text and just do string searches on each line read? I can do that already but it's horribly inefficient.

Cheers,
Brian


PS unless I'm missing something, I can't find anything in the GBPVR.Public namespace which allows me to access the original file - only the EPG data in the database.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,717
Threads: 767
Joined: Nov 2003
#2
2005-10-27, 08:26 PM
I do the following
KingArgyle
Offline

Posting Freak

Posts: 1,271
Threads: 95
Joined: Nov 2004
#3
2005-10-27, 11:48 PM
You need to recast your XmlNode to an XmlElement. The XmlElement has a GettAttribute method on it that takes the name of the attribute. An example used in CDK Scheduler:

Code:
XmlNode node2 = node.SelectSingleNode("Start");
XmlElement element = (XmlElement) node2;
string timeValue = element.GetAttribute("time");

The above is C# code, but should be transferable to VB.NET
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#4
2005-10-27, 11:48 PM
Thanks sub - the following does it for me...

Code:
For Each TempNode1 In ProgrammeList

    strStartTime = TempNode1.Attributes("start").InnerText
    strStopTime = TempNode1.Attributes("stop").InnerText
    strChannelID = TempNode1.Attributes("channel").InnerText

    blah...
It was the Attributes bit I hadn't picked up on - your attachment showed me that.

I need to buy me a book on XML and stop trying to write VB.NET code (converted from VB6) using examples from a C# book. Big Grin

Cheers,
Brian
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,717
Threads: 767
Joined: Nov 2003
#5
2005-10-27, 11:56 PM
You're using DOM parsing, wheras my code is SAX parsing. DOM is typically easier to understand. SAX tends to work faster and more efficiently on large files - but DOM is fine for the size datasets you'd be dealing with for XMLTV.
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#6
2005-10-28, 03:05 AM
DOM? SAX? No idea what you're talking about. Pah! Young people these days with their silly acronyms. I've got a white patch in my beard, I'll have you know - and I use SOAP to wash my hands. mumble. mumble.

Seriously though - using this approach, rather than treating the XML file as raw text and using search strings, has reduced the time it takes by about a third. The XPath approach gives me limited query capabilities which is what I need.

Thanks again for the help. Cheers.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  How to extract M3U8 and get matching XMLTV guide data from NPVR almightyj 0 3,449 2018-10-23, 07:24 AM
Last Post: almightyj
  XMLTV Channel Number Option gdogg371 12 6,801 2018-07-18, 04:32 PM
Last Post: sub
  Merge xmltv data with xslt Graham 4 3,475 2014-01-02, 12:45 PM
Last Post: Graham
  New web service clarification needed bgowland 6 3,237 2013-10-19, 02:36 AM
Last Post: bgowland
  Skin help needed for EventDetails.xml bgowland 7 3,327 2011-06-26, 11:55 PM
Last Post: Jaggy
  XMLTV data mvallevand 6 2,639 2011-04-16, 03:08 AM
Last Post: sub
  Free XMLTV EPG scraper dneprrider 214 100,037 2010-03-29, 04:54 AM
Last Post: dljones8053
  MVP/NMT testers needed for Weather2 scb147 46 11,857 2010-03-03, 08:12 PM
Last Post: scb147
  XmlTv Structure psycik 2 2,218 2008-12-29, 10:53 PM
Last Post: psycik
  Content Provider: How to publish XMLTV data? skoka123 6 3,449 2008-09-03, 05:48 AM
Last Post: skoka123

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode