NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 71 72 73 74 75 … 93 Next »
Search Confg.xml

 
  • 0 Vote(s) - 0 Average
Search Confg.xml
Ron22
Offline

Member

Posts: 132
Threads: 29
Joined: Feb 2005
#1
2005-05-10, 09:32 PM
Remember I am new to C# and .net program so be nice Smile
How would I search the config.xml passed to the plugin for a partial string? I want to search for “MAC-“
I am currently using
XmlNode node = doc.SelectSingleNode("/settings/MVPWidth")
to read in the sections I want.
Currently the only thing I can think of is using NextSibling and stepping through the file and comparing them. Is there an easier way?
Windows XP Home
P4 2.6GHz - 768MB Ram 980GB 4 - HDD's
3 MVP
1 PVR-150
1 PVR-250
KingArgyle
Offline

Posting Freak

Posts: 1,271
Threads: 95
Joined: Nov 2004
#2
2005-05-10, 11:00 PM
Quote:XmlNode node = doc.SelectSingleNode("/settings/MVPWidth")

Are you trying to get all the MVPWidths regardless of MAC address, if so, you might be able to do something likeL

/settings/*/MVPWidth

Which would return you a Nodeset of all the MVPWidth elements. You could then use the ParentNode function to get the element's name that that particular element belongs to.

Personally, if you are wanting the name of the name of each MAC address that is specified, you might be able to use a combination of the XPath name() function and the node() functions.

Something like the following might get you the name, but I haven't tested this:

/settings/*/MCPWidth[contains(name(parent), 'MAC')]


Personally, I'd like to see a bit of redesign for the config XML file when it comes to storing the MAC addresses. Something like the following:

Code:
<settings>
    <MVP>
        <MACSettings>
               <Address>MAC-000DFEE029B2</Address>
               <MVPWidth>600</MVPWidth>
               <MVPHeight>400</MVPHeight>
               <MVPOffsetX>44</MVPOffsetX>
               <MVPOffsetY>50</MVPOffsetY>
       </MACSettings>
    </MVP>
</settings>


A list of the various XPath functions can be found here:
http://www.w3.org/TR/xpath#section-String-Functions
Ron22
Offline

Member

Posts: 132
Threads: 29
Joined: Feb 2005
#3
2005-05-10, 11:30 PM
What I am trying to do is get each MAC-000DFEE029B2 listing. Then for my plugin I can automatically pull in all the current MAC address in the config.xml file.
Windows XP Home
P4 2.6GHz - 768MB Ram 980GB 4 - HDD's
3 MVP
1 PVR-150
1 PVR-250
jasonf
Offline

Member

Posts: 121
Threads: 7
Joined: Oct 2004
#4
2005-05-11, 12:42 AM (This post was last modified: 2005-05-11, 12:43 AM by jasonf.)
I think I understand what you want. Consider the following code:

Code:
string x = "<config>"
    +  "<MAC-000DFEE029B2><MVPWidth>600</MVPWidth><MVPHeight>400</MVPHeight><MVPOffsetX>44</MVPOffsetX><MVPOffsetY>50</MVPOffsetY></MAC-000DFEE029B2>"
    +  "<MAC-0223333B2><MVPWidth>600</MVPWidth><MVPHeight>400</MVPHeight><MVPOffsetX>44</MVPOffsetX><MVPOffsetY>50</MVPOffsetY></MAC-0223333B2>"
    +  "<MAC-abcde><MVPWidth>600</MVPWidth><MVPHeight>400</MVPHeight><MVPOffsetX>44</MVPOffsetX><MVPOffsetY>50</MVPOffsetY></MAC-abcde>"
    +  "</config>";

System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
xml.LoadXml(x);

System.Xml.XmlNodeList nl= xml.SelectNodes("//MVPWidth/..");

foreach (System.Xml.XmlNode n in nl)
    Console.WriteLine(n.Name);

Console.ReadLine();

What's important here is the XPath of: "//MVPWidth/.."

This will return a nodeset of all parent nodes that have a MVPWidth child anywhere in the document.

The code above produces:

Code:
MAC-000DFEE029B2
MAC-0223333B2
MAC-abcde
JasonF
jasonf
Offline

Member

Posts: 121
Threads: 7
Joined: Oct 2004
#5
2005-05-11, 12:48 AM
Oh, and if you're worried that there might be other MVPWidth nodes in config and you want to make sure that you're getting the right MAC nodes, you can try an XPath like the following instead:

Code:
System.Xml.XmlNodeList nl= xml.SelectNodes("//node()[MVPWidth and MVPHeight and MVPOffsetX and MVPOffsetY]");

This XPath returns a nodeset of nodes that have a MVPWidth child AND a MVPHeight child AND a MVPOffsetX child AND a MVPOffsetY child.

Hopefully this makes things a little clearer as to some querying possibilities using XPath.
JasonF
Ron22
Offline

Member

Posts: 132
Threads: 29
Joined: Feb 2005
#6
2005-05-11, 03:23 AM
Thanks for the help. I was able to do what I wanted after you example.

jasonf Wrote:Hopefully this makes things a little clearer as to some querying possibilities using XPath.
A little clear still a lot to learn.
Windows XP Home
P4 2.6GHz - 768MB Ram 980GB 4 - HDD's
3 MVP
1 PVR-150
1 PVR-250
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Roku channel for NPVR with Search & Schedule ioan 12 11,685 2013-03-31, 01:34 AM
Last Post: btpoole
  Multiple lists like in Search Screen cncb 7 3,256 2012-08-08, 09:11 PM
Last Post: cncb
  Netflix Search and Viewer dhgb256 153 43,570 2009-11-10, 11:35 PM
Last Post: Snooze
  Google Code Search Graham 1 1,315 2007-03-29, 05:34 PM
Last Post: McBainUK
  Any xmltv users willing to test some new search features? Jim_ 14 4,368 2006-10-11, 07:40 PM
Last Post: Jim_
  Sql search programming question jorm 2 1,738 2004-11-18, 06:11 PM
Last Post: jorm
  Search for Episodes by Keyword KingArgyle 0 1,256 2004-11-14, 11:37 PM
Last Post: KingArgyle
  In search of aegisx 9 3,376 2004-11-10, 07:21 PM
Last Post: jorm
  Search Plugin aegisx 2 2,122 2004-10-11, 07:28 PM
Last Post: aegisx

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

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

Linear Mode
Threaded Mode