0

I have this string;

<div class="flip-entry-title">System~1584~CommandName-e.dat</div></div><div class="flip-entry-last-modified"><div>18 Αυγ</div></div></div><div class="flip-entry" id="entry-0B4jdixTeku1LMlpNdEtOSmhxWWM" 

What is the best efficient way to pick System~560~Charcreategrp.dat and entry-0B4jdixTeku1LMlpNdEtOSmhxWWM

I know I can use Regex.split and substring(x, y) but I want to know if theres a class or a method in C# that will do this job for me.

waka
  • 3,362
  • 9
  • 35
  • 54
user3789587
  • 105
  • 1
  • 1
  • 6

2 Answers2

1

If it is always XML (or HTML) you could parse it

XmlDocument doc = new XmlDocument();
doc.LoadXml(myStr);

And then use XPath or Linq to fetch what you need from doc.

ZoolWay
  • 5,411
  • 6
  • 42
  • 76
1

If they are not good for your case take a look at these:

Can you explain why Regex and substring() are no option?

Update: Ok, I understand. As you know working with String may be slow - you can try StringBuilder (way faster), but 2-400 operations can be high number, when you append/join or split/search.

split and substring make the code unreadable and too complex,

Even if you think so - you can always create proper comments...self-documenting/explanatory code is very helpful and is one of the best-practices.

ekostadinov
  • 6,880
  • 3
  • 29
  • 47
  • split and substring make the code unreadable and too complex, since i have an unknown number of strings 200 - 400 that I have to process – user3789587 Aug 19 '14 at 10:53
  • Also, I get those HTML string from the web, their order/contents may change at any time so I need a more generic aproach – user3789587 Aug 19 '14 at 10:55