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.
Best way to get data from web site.
Page 1 of 17 Replies - 321 Views - Last Post: 06 July 2011 - 12:15 PM
Replies To: Best way to get data from web site.
#2
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.
#3
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.
#4
Re: Best way to get data from web site.
Posted 06 July 2011 - 11:40 AM
#5
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!
#6
Re: Best way to get data from web site.
Posted 06 July 2011 - 11:55 AM
You can use Split:
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.
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.
#7
Re: Best way to get data from web site.
Posted 06 July 2011 - 11:55 AM
Regular expressions would work just fine.
#8
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.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote








|