Remove_String Issue
jabramson
Posts: 106
I'm baffled by this one. Using the Remove_String Command to parse some data that is returned from an XML sheet.
Here is the data returned:
and the code to parse it
the nWEB_TEMPERATURE returns the proper value, but the cWEB_ICON always returns the icon code plus </Icon> on the end and I cannot figure out why. (I know the cTRASHer is not needed, just added to see the data passed). The </Weather> data is left in the cWebBuffer.
Any idea why it's grabbing the </Icon> as well? I'm sure it's something rather simple.
Here is the data returned:
Alive Content-Type: text/plain <WeatherData><Temperature>45</Temperature><Icon>partlycloudy</Icon></WeatherData>
and the code to parse it
cTRASHer = REMOVE_STRING(cWebBuffer,'<Temperature>',1) nWEB_TEMPERATURE=atoi(REMOVE_STRING(cWebBuffer,'</Temperature>',1)) cTRASHer=REMOVE_STRING(cWebBuffer,'<Icon>',1) cWEB_ICON=REMOVE_STRING(cWebBuffer,'</Icon>',1)
the nWEB_TEMPERATURE returns the proper value, but the cWEB_ICON always returns the icon code plus </Icon> on the end and I cannot figure out why. (I know the cTRASHer is not needed, just added to see the data passed). The </Weather> data is left in the cWebBuffer.
Any idea why it's grabbing the </Icon> as well? I'm sure it's something rather simple.
0
Comments
Look Here
http://www.amxforums.com/showthread.php?8675-Processing-Received-Strings&p=60394#post60394
In this example, we know that '</icon>' is 7 characters, so the above statement would equate to "give me my buffer minus the last 7 characters."
I've never really given the efficiency aspect any consideration but moving a pointer and referencing pointers should definitely be more efficient and probably a more eloquent way to go about it. I'm more a bull in a china shop kinda guy compared to a ballet dancer who has grace, style and fluidity in motion.