Extracting Field values for XML file

i have an input file of XML type with data like

<nx-charging:additional-parameter name="NX_INTERNATIONALIZED_CLID" value="919427960829"/><nx-charging:finalStatus>RESPONSE , Not/Applicable , OK</nx-charging:finalStatus></nx-charging:process>

i want to extract data such that i get the output like:

additional-parameter name=NX_INTERNATIONALIZED_CLID
value=919427960829
finalStatus=RESPONSE Not/Applicable , OK

i have done some coding for it

#include <stdio.h>
#include <string.h>

int main()
{

char DataIn[] = "<nx-charging:additional-parameter name=\"NX_INTERNATIONALIZED_CLID\" value=\"919427960829\"/><nx-charging:finalStatus>RESPONSE , Not/Applicable , OK</nx-charging:finalStatus></nx-charging:process>";

char *str = DataIn;
char *token;
while ( (token = strtok ( str, ":<>/" )) )
{
puts(token);
str = 0;
}
return 0;
}

But my output comes as:

/***OUTPUT*****

nx-charging
additional-parameter name="NX_INTERNATIONALIZED_CLID" value="919427960829"
nx-charging
finalStatus
RESPONSE , Not
Applicable , OK
nx-charging
finalStatus
nx-charging
process

the fields highlighted are not required by me.

Plus the fields

finalStatus
RESPONSE , Not
Applicable , OK

should come as

finalStatus=RESPONSE Not/Applicable , OK

please suggest me some changes.

For starters do not set a pointer to 0 but use NULL instead...so "str = NULL" is good. Also get the token you want and after you get it extract the desired sub-tokens from it. Does it make sense or have I managed to :confused: you utterly.

i have changed the code a little

char DataIn[] = "<nx-charging:additional-parameter name=\"NX_INTERNATIONALIZED_CLID\" value=\"919427960829\"/><nx-charging:finalStatus>RESPONSE , Not/Applicable , OK</nx-charging:finalStatus></nx-charging:process>";

char *str = DataIn;
char *token[500];

while ( (token [i]= strtok ( str, "<" )) )
{
puts(token[i]);
i++;
str = NULL;
}

this is how my output looks like

nx-charging:additional-parameter name="NX_INTERNATIONALIZED_CLID" value="919427960829"/>
nx-charging:finalStatus>RESPONSE , Not/Applicable , OK
/nx-charging:finalStatus>
/nx-charging:process>

the highlighted fields are not required by me

also " in the output are not required.

and for this out put
finalStatus>RESPONSE , Not/Applicable , OK
i want it to be like
finalStatus=RESPONSE , Not/Applicable , OK

thanks for replies, waiting for more to come.

int main()
{
    char DataIn[] = "<nx-charging:additional-parameter name=\"NX_INTERNATIONALIZED_CLID\" value=\"919427960829\"/><nx-charging:finalStatus>RESPONSE , Not/Applicable , OK</nx-charging:finalStatus></nx-chargingrocess>";

    int n = 0;
    char *str = DataIn;
    char *token, *subtok;

    while (token = strtok(str, ":" )) {
        ++n;
        if (n == 3) {
            if (subtok = strtok(token, ">"))
                printf("%s=", subtok);
            if (subtok = strtok(NULL, "<"))
                puts(subtok);
        }
        str = NULL;
    }
    return 0;
}