Hello I have a task to write a program, that prints out certain words from HTML code. For example we have this HTML code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<body>
<div>
<p>2014</p>
<span> wasap </span>
</div>
<div>
<p> 2013 </p>
<span> hahahaha labas </span>
</div>
<div>
<p> 2012 </p>
<span> blalbalba </span>
</div>
</body>
</html>
So the output should look like this: wasap hahahaha labas blablabla
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LENGHT 2048
struct htmlCode {
char subjectName[20];
char c[MAX_LENGHT - 1];
} htmlCode;
int main() {
int i = 0, size = 0;
struct htmlCode dataSubject[100];
char span1[6];
char span2[7];
FILE *fp = fopen("duomenys.txt", "r");
while (!feof(fp)) {
fscanf(fp, "%s", &htmlCode.c);
size++;
//printf("%d %s\n", size, c);
}
//printf("%d\n", size);
rewind(fp);
if (fp) {
while (!feof(fp)) {
for (i = 0; i < size; i++) {
fscanf(fp, "%s", &htmlCode.c);
strcpy(dataSubject[i].c, htmlCode.c);
//printf("%d %s\n", i, dataSubject[i].c);
if (feof(fp))
break;
}
}
}
printf("%d\n", size);
strcpy(span1, "<span>");
printf("%s\n", span1);
strcpy(span2, "</span>");
printf("%s\n", span2);
rewind(fp);
for (i = 0; i < size; i++) {
if (dataSubject[i].c == span1) {
printf("%s\n", dataSubject[i].c);
}
}
fclose(fp);
return 0;
}
Can anyone help me with that please?