Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: parse text from class of complex html file

$
0
0
Hi.
First of all I'm a beginner in programming.

I just want to get the text of a class from a html file (website).

Here is the html code (the selected class "lyrics-body"):
Image

And my code:
String strLyricsWebsite = "http://www.lyricsmania.com/";
String strInterpReplace = strInterp.Replace(" ", "_");
String strSongReplace = strSong.Replace(" ", "_");
String strUrlZusammen = String.Concat(strLyricsWebsite, strSongReplace, "_lyrics_", strInterpReplace, ".html");

lblUrlTest.Text = strUrlZusammen;

                    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                    doc.LoadHtml(strUrlZusammen);
                    HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@class='lyrics-body']");
                    string webText = node.InnerText;

                    strPfadDatei = webText;
whats the problem with my code ?
the program is crashing with that code.

Why is there such an easy command for an ID ( GetElementbyID) but not for a class ? :/

I've searched for hours for a resolution but nothing worked :(
Remember: I'm a total beginner in programming^^

Sorry for my bad english
Hope you can help me

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>