I'm trying to create a function that prints out an XML tag with a value. I have the code below, but kind of stuck. I'd like to be able to call the function, and pass a value that could be a float, int, string or char. Appreciate any help.
char PingTime[6] = "3ms";
char PingText[60] = "ping reply blah blah";
float humidity = "40.56";
int DigialPin = 0;
PrintXMLTag(cl,"pingtime",PingTime);
PrintXMLTag(cl,"PingText",PingText);
PrintXMLTag(cl,"humidity",humidity);
PrintXMLTag(cl,"DigialPin",DigialPin);
void PrintXMLTag_DEC(EthernetClient cl, const char* tag, NotSure?? val)
{
char tmp [100];
StrClear(tmp,100);
// If val type is float ----------------------
int d1 = val; // Get the integer part
float f2 = val - d1; // Get fractional part
int d2 = trunc(f2 * 10000);// Turn into integer
sprintf(tmp,"<%s>%d.%02d</%s>\n",tag,d1,d2,tag);
// end float
// If val type is string ----------------------
// If val type is int ----------------------
// If val type is char ----------------------
cl.print(tmp);
}