Click here to Skip to main content
16,012,508 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to create a jagged array of multiple data-type data? Pin
Guffa15-Dec-08 12:03
Guffa15-Dec-08 12:03 
QuestionLoading Multiple Images to a Picture Box Pin
User 543536414-Dec-08 14:19
User 543536414-Dec-08 14:19 
AnswerRe: Loading Multiple Images to a Picture Box Pin
Christian Graus14-Dec-08 17:17
protectorChristian Graus14-Dec-08 17:17 
GeneralRe: Loading Multiple Images to a Picture Box Pin
User 543536414-Dec-08 17:30
User 543536414-Dec-08 17:30 
GeneralRe: Loading Multiple Images to a Picture Box Pin
Lev Danielyan14-Dec-08 19:16
Lev Danielyan14-Dec-08 19:16 
QuestionC# Xml struggles Pin
lszanto14-Dec-08 12:56
lszanto14-Dec-08 12:56 
AnswerRe: C# Xml struggles Pin
lszanto14-Dec-08 12:58
lszanto14-Dec-08 12:58 
AnswerRe: C# Xml struggles Pin
Colin Angus Mackay14-Dec-08 14:20
Colin Angus Mackay14-Dec-08 14:20 
If you are using .NET 3.5 then I'd use the new System.Linq.Xml classes.

Also, you need to get the HTTP content - And you have to provide a safe way of generating the URL.

To generate your URL, use something like this as it will ensure that any characters in the Artist and Name properties are correctly encoded for use in a URL.
string url = string.Concat(
    "http://lyricsfly.com/api/api.php?i=de5abbf415fd84ca6-temporary.API.access&a=",
    HttpUtility.UrlEncode(track.Artist),
    "&t=",
    HttpUtility.UrlEncode(track.Name));


Now, to get the data you need to get it from the internet. To do this you need to do something like this:
string data;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (Stream stream = response.GetResponseStream())
{
    StreamReader reader = new StreamReader(stream);
    data = reader.ReadToEnd();
}


HttpWebRequest and HttpWebResponse are in System.Net namespace.

Now, to convert that data into an XML object graph you can use:
XElement doc = XElement.Parse(data);


From this point onwards you can use LINQ syntax to query the XML, or you can do it yourself.

For example, to get all the Songs (I presume that's what element "sg" is) you can do this:
IEnumerable<XElement> = doc.Elements("sg");


To get the lyrics of the first song, this should work:
string lyrics = doc.Element("sg").Element("tx").Value;


Does this help?


GeneralRe: C# Xml struggles Pin
lszanto14-Dec-08 14:33
lszanto14-Dec-08 14:33 
QuestionForm turning into component Pin
kod3brkr14-Dec-08 12:41
kod3brkr14-Dec-08 12:41 
AnswerRe: Form turning into component Pin
Colin Angus Mackay14-Dec-08 14:07
Colin Angus Mackay14-Dec-08 14:07 
GeneralRe: Form turning into component Pin
kod3brkr14-Dec-08 14:19
kod3brkr14-Dec-08 14:19 
GeneralRe: Form turning into component Pin
Colin Angus Mackay14-Dec-08 14:27
Colin Angus Mackay14-Dec-08 14:27 
GeneralRe: Form turning into component Pin
kod3brkr14-Dec-08 16:07
kod3brkr14-Dec-08 16:07 
GeneralRe: Form turning into component Pin
Colin Angus Mackay14-Dec-08 21:37
Colin Angus Mackay14-Dec-08 21:37 
GeneralRe: Form turning into component Pin
Luc Pattyn15-Dec-08 0:33
sitebuilderLuc Pattyn15-Dec-08 0:33 
QuestionCan I add new fields to an existing type using reflection( FieldBuilder) ? Pin
Charith Jayasundara14-Dec-08 11:04
Charith Jayasundara14-Dec-08 11:04 
AnswerRe: Can I add new fields to an existing type using reflection( FieldBuilder) ? Pin
Colin Angus Mackay14-Dec-08 12:17
Colin Angus Mackay14-Dec-08 12:17 
GeneralRe: Can I add new fields to an existing type using reflection( FieldBuilder) ? Pin
Lev Danielyan14-Dec-08 19:37
Lev Danielyan14-Dec-08 19:37 
GeneralRe: Can I add new fields to an existing type using reflection( FieldBuilder) ? Pin
Charith Jayasundara14-Dec-08 22:45
Charith Jayasundara14-Dec-08 22:45 
GeneralRe: Can I add new fields to an existing type using reflection( FieldBuilder) ? Pin
Lev Danielyan14-Dec-08 23:52
Lev Danielyan14-Dec-08 23:52 
QuestionDataGridViewComboBoxColumn, how the bound dataset into the datagridview. Pin
leeoze14-Dec-08 9:58
leeoze14-Dec-08 9:58 
AnswerRe: DataGridViewComboBoxColumn, how the bound dataset into the datagridview. Pin
basambora14-Dec-08 10:50
basambora14-Dec-08 10:50 
GeneralI tried to replace but there is a problem: Pin
leeoze14-Dec-08 18:48
leeoze14-Dec-08 18:48 
QuestionSin(pi) = 3,23108510433268E-15 Pin
Fernando I14-Dec-08 7:34
Fernando I14-Dec-08 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.