Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<b>HTML and C/C++</b>

Status
Not open for further replies.
Well...
You could try to find some API's for a DOM (Document object model), which is something that is specially implemented for XML or you can try to find some simple XML parsers. It works also with HTML files, but there is a little extra work you have to do there to get the result you want.
Expat is simple enough toolkit for XML parsing ( but again... this is for XML.

Or, you could just easily write your own routine for string manipulations, and use strstr function to get pointers to the beginning and the end of the link.
Supposing you have the whole line in you string, you could say:

Code:
char *startlink,*endlink;
char *thelink;
int count;

startlink = strstr(&quot;<a href=&quot;,line);
endlink = strstr(&quot;>&quot;,line);
count = endlink-startlink;
thelink = (char *)malloc(count + 1);
strncpy(thelink,startlink,count);
thelink[count+1] = 0;

This should do it, of course, with additional checking on the pointers...

Hope this helps. Nosferatu
We are what we eat...
There's no such thing as free meal...
 
You could parse the file a character at a time when a &quot;<&quot; is found looking for the &quot;>&quot;

something like

ifstream in(&quot;input.txt&quot;);

char buffer[256];
in.getline(buffer,256,'<');// reads til '<'

while(in.get() != '>')
;

loop this (or something along these lines) and you should be good to go.

Matt
 
you can use DHTML activeX ovject. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top