Help with taking out part of string

  • Thread starter Thread starter Aahz
  • Start date Start date
A

Aahz

Hello,

Can someone help me with this: I have taken string frm an html source,
and it looks like this:
<a class="v11" href=Sweden-232433.html>Sweden</a> (30millions)

Now I am trying to take out name of the state(in this case "Sweden").
What is best way to do this? Using RegEx validator?

I was thinking to make regex validation that takes strings between
values ".html>" and "</a> (" ?
Can it be done that way or should I do something else?

Thanks
 
Hello,

Can someone help me with this: I have taken string frm an html source,
and it looks like this:
<a class="v11" href=Sweden-232433.html>Sweden</a> (30millions)

Now I am trying to take out name of the state(in this case "Sweden").
What is best way to do this? Using RegEx validator?

I was thinking to make regex validation that takes strings between
values ".html>" and "</a> (" ?
Can it be done that way or should I do something else?

Thanks

Well,

If it had been href="Sweden-232433.html" like it ought to be instead of no
" you could treat it like Xml and load it into an XmlDocument and read the
InnerText

string s = "<a class=\"v11\" href=\"Sweden-232433.html\">Sweden</a>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(s);

string value = doc.ChildNodes[0].InnerText;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top