I am creating a program in c that finds out the weather and changes the desktop background accordingly. So far i have managed to connect to the internet and DL the bbc rss feed to the file, which i can then open up. I have almost managed to get it to edit the registry to change the desktop background.
Atm i am trying to parse the file to extract the word sunny form an XML line
int main(void)
{
char word[128];
char *p, prefix;
int i;
char string[] = "<title>Saturday: sunny, Max Temp: 16°C (61°F), Min Temp: 4°C (39°F)</title>";
prefix = ',';
p = strchr(string, prefix);
if(p == NULL) {
printf("No %c found.\n", prefix);
}
else {
i = p-string;
printf("Found weather at position: %d\n", prefix, i+1);
strncpy(word, &string[0], i);
word[i] = '\0';
printf("Weather is: [%s]\n", word);
}
return 0;
}
I have managed to get it to extract everything before the comma
eg Weather is: <title>Saturday: sunny
How do i get it to parse the ":" and just leave the word sunny
(also i have just manually written in the string, how would i get it to find that line in a big XML file, would i have to parse the whole file? or can i somehow select that line number or something?)
Thank you
Phil