也大多是我使用MXML庫在這樣的條件,但在這裏,你只是想xml文件不用想解析,那麼你可以直接作出這樣的xml文件,就像這樣
#include<stdio.h>
struct my_data
{
int number;
char string[10];
};
void createdata(FILE *fb,struct my_data testData)
{
fprintf (fb,"<Data>\n");
fprintf (fb,"<number> %d </number>\n",testData.number);
fprintf (fb,"<string> %s </string>\n",testData.string);
fprintf (fb,"</Data>\n");
}
int main()
{
FILE *fb=fopen("test.xml","w");
struct my_data testData = {32,"Mr.32"};
fprintf (fb,"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
createdata(fb,testData);
return 0;
}
這只是圍脖代碼,以幫助你去思考...此代碼使初級講座xml文件
-
<Data>
<number> 32 </number>
<string> Mr.32 </string>
</Data>