7 Replies - 549 Views - Last Post: 06 July 2011 - 12:15 PM Rate Topic: -----

#1 IYIaster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-July 11

Best way to get data from web site.

Posted 06 July 2011 - 10:39 AM

I'm new to C# programming. Started my first program yesterday. I've done some Java programming in the past and wanted to jump into the C# game since it's similar. I'm not a great programming and if you guys were to look at my code you would laugh. The program will get titles from an RSS feed. I already got that part working using xpath. Next it will use those titles to do a search. The data that it receives from that search is what I'm trying to figure out the best way to get. There is a lot data from that search, but what I need is the very first part and it will be in this format, id:980683;. I just need the numbers. Can someone point me in the right direction please. Thanks for your time.

Is This A Good Question/Topic? 0
  • +

Replies To: Best way to get data from web site.

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9574
  • View blog
  • Posts: 36,262
  • Joined: 12-June 08

Re: Best way to get data from web site.

Posted 06 July 2011 - 11:10 AM

It seems pretty straight forward - use the string class's method of "replace" on "id:" and replace it with an empty string.
Was This Post Helpful? 0
  • +
  • -

#3 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Best way to get data from web site.

Posted 06 July 2011 - 11:18 AM

If the ; is part of the data, be sure to Replace that as well.
Was This Post Helpful? 0
  • +
  • -

#4 IYIaster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-July 11

Re: Best way to get data from web site.

Posted 06 July 2011 - 11:40 AM

View PostCurtis Rutland, on 06 July 2011 - 11:18 AM, said:

If the ; is part of the data, be sure to Replace that as well.

That is pretty straight forward, but what about all the data after the ; how do I get rid of that?
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9574
  • View blog
  • Posts: 36,262
  • Joined: 12-June 08

Re: Best way to get data from web site.

Posted 06 July 2011 - 11:49 AM

There's data afterwards? That wasn't shown in the example!
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Best way to get data from web site.

Posted 06 July 2011 - 11:55 AM

You can use Split:

var temp = "id:980683;asdfasdf;lkjho;wiuh29083hlio;uwndlf;8hujfn;l98h243lifubh";
var idNum = temp.Split(':', ';').Skip(1).First();
var idNumAlt = temp.Split(':', ';')[1];



idNum and idNumAlt give the same results, they just use a different mechanism. I like the first, but that'll only work on .NET 3.5 and higher.
Was This Post Helpful? 0
  • +
  • -

#7 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 948
  • View blog
  • Posts: 2,357
  • Joined: 15-February 11

Re: Best way to get data from web site.

Posted 06 July 2011 - 11:55 AM

Regular expressions would work just fine.
Was This Post Helpful? 0
  • +
  • -

#8 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Best way to get data from web site.

Posted 06 July 2011 - 12:15 PM

Quote

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.


--Quoted from this page.

Regex is heavy and complicated for a relatively minor task. I'd avoid using them except for problems that can't be simply solved with splitting/replacing/trimming.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1