printing a string between indicies (data between xml tags)
hi everyone,
i seem to be having a simple printing error...which relates to simply printing between two indicies of a string (ie. char)
eg. if i give the indices 1 and 4....in the string helloWorld - it should print hell
ok...in my code, i am reading in a file line by line from the internet using the program wget (through a pipe) in unix...and searching it using the regex.h library and regular expressions...BTW you dont need to understand any of this to help me
the file im reading in is just a simple xml file...ie
<title> monsters rule </title>
i then do a simple search for all of that title, including the title tags..it returns me with the indicies of the first < of title and ending > of /title
so in this case it would return me start index=1 and end index=27
now all i want to do is store the data between the title tags in a string..so i cant print it...this is how i do it....please tell me if you know a better way!
i calculate the length of <title> and </title>
and then i add the length of <title> to the start index
and subtract the length of </title> from end index
<title> monsters rule </title>
so in this case above my start index will nolonger be on < (1), it will be on the space (8)
similarly with the end index...
now all i need to do is print each character of the string between the indices...i did this...and it does work for most cases...
but in some instances it prints out some weird stuff
ie. here is a tag im reading in...
<link>http://monstersAreHereE.com/today</link>
so i have this in a string and i apply what i said earlier to remove the link tags...therefore when i print between the tags, it should print
http://monstersAreHereE.com/today
instead i get http://monstersAreHereE.com/today>>▼
heres a small block of my code where this is done..
ive also attached my full code
i would appreciate any help..in regards to why it doesnt print what i want...please be specific cause ive spent hours trying to debug this thing and i cant find whats the problem
thanks for reading this message / and hopefully helping me.. :)