#include"stdio.h"
#include"string.h"
char MXL_11[]="<CategoryInfo><RecordCount>7</RecordCount><CategoryList><CategoryLine><SpCategoryID>1</SpCategoryID><SpCategoryName>电影</SpCategoryName></CategoryLine><CategoryLine><SpCategoryID>2</SpCategoryID><SpCategoryName>电视剧</SpCategoryName></CategoryLine><CategoryLine><SpCategoryID>3</SpCategoryID><SpCategoryName>动漫</SpCategoryName></CategoryLine><CategoryLine><SpCategoryID>4</SpCategoryID><SpCategoryName>综艺</SpCategoryName></CategoryLine><CategoryLine><SpCategoryID>5</SpCategoryID><SpCategoryName>体育</SpCategoryName></CategoryLine><CategoryLine><SpCategoryID>6</SpCategoryID><SpCategoryName>新闻</SpCategoryName></CategoryLine><CategoryLine><SpCategoryID>7</SpCategoryID><SpCategoryName>游戏</SpCategoryName></CategoryLine></CategoryList></CategoryInfo>";
int Num_Antistop[]={4,14,3};
char *p[][20]=
{
// --分类列表接口
{
"<RecordCount>", // <!-记录数-->
"<CategoryLine>", //
"<SpCategoryID>", // <!-总页数-->
"<SpCategoryName>" // <!-节目编号-->
},
// --节目列表接口
{
"<RecordCount>",
"<TotalPage>",
"<ProgramLine>",
"<ProgramID>",
"<ProgramName>",
"<ProgramDirector>", //
"<ProgramActor>",
},
// --节目详细信息接口
{
"<ProgramID>",
"<ProgramName>",
"<ProgramActor>",
}
};
enum divide //划分
{
Category,
Program,
Program_Detail
};
//分类列表
enum Category
{
Category_Count,
Category_Line,
Category_ID,
Category_Name
};
//节目列表
enum Program
{
Program_Count,
Program_TotalPage,
Program_Line,
Program_ID,
Program_Name,
Program_Director, //
Program_Actor,
};
//节目详细
enum Program_Detail
{
Program_Detail_ID,
Program_Detail_Name,
Program_Detail_Actor,
Program_Detail_Picture,
Program_Detail_Summary, //摘要
Program_Detail_Year, //上映时间
Program_Detail_Area, //所属地区
Program_Detail_Duration, //持续时间
Program_Detail_Bitrate, //比特率
Program_Detail_Resolution,//分辨率
Program_Detail_LinkCount,
Program_Detail_LinkLine,
Program_Detail_LinkName,
Program_Detail_LinkString
};
typedef struct
{
//分类列表的数据结构
char *p_Count;
int len_Count;
char *p_CategoryID;
int len_CategoryID;
char *p_CategoryName;
int len_CategoryName;
}CategoryInfoTYPE;
#define MAX_CATEGORY_NUM 100 //能承受的最大分类数
CategoryInfoTYPE CategoryInfoData[MAX_CATEGORY_NUM];
typedef struct
{
//节目列表的数据结构
char *p_Count;
int len_Count;
char *p_TotalPage;
int len_TotalPage;
char *p_ProgramID;//节目编号
int len_ProgramID;
char *p_ProgramName;//节目名称
int len_ProgramName;
char *p_ProgramDirector;//导演
int len_ProgramDirector;
// char *p_xxxx;
// int len_xxxx;
}ProgramInfoTYPE;
#define MAX_PROGRAM_INFO_NUM 100 //一次性解析和保存的最大电影数
ProgramInfoTYPE ProgramInfoData[MAX_PROGRAM_INFO_NUM];
void Get_INFO(int Divi,char *Array);
void insertch(char *p,char *q);
void screen();
void main()
{
Get_INFO(0,MXL_11);
screen();
}
//输入 Divi“类别”信息 Array 数组
void Get_INFO(int Divi,char *Array) //divi 取值 0 1 2
{
int a_len,len=0,i,j=0;
int point;
int Num=0;
char a[80];
a_len = strlen(Array);
for(i=0;i<a_len;i++)
{
if(Array[i]=='<')
{
while(Array[i] != '>')
{
a[j] = Array[i];
j++;
i++;
}
point=i+1;
a[j]='>';
a[j+1]='\0';
for(j=0;j<Num_Antistop[Divi];j++) // 条件需要用变量
{
if(strcmp(a,p[Divi][j])==0)
{
while(Array[i] != '<')
{
len++;
i++;
}
switch(Divi)
{
case Category:
{
switch(j)
{
case Category_Count:
CategoryInfoData[Num].p_Count = &Array[point];
CategoryInfoData[Num].len_Count = len-1;
break;
case Category_Line:
Num++;
--i; //边界问题
break;
case Category_ID:
CategoryInfoData[Num].p_CategoryID = &Array[point]; //&MXL_11[i];
CategoryInfoData[Num].len_CategoryID = len-1;
break;
case Category_Name:
CategoryInfoData[Num].p_CategoryName = &Array[point];
CategoryInfoData[Num].len_CategoryName = len-1;
}
}break;
case Program:
{
switch(j)
{
case Program_Count:
ProgramInfoData[Num].p_Count = &Array[point];
ProgramInfoData[Num].len_Count = len-1;
break;
case Program_TotalPage:
ProgramInfoData[Num].p_TotalPage = &Array[point];
ProgramInfoData[Num].len_TotalPage = len-1;
break;
case Program_Line:
Num++;
--i; //边界问题
break;
case Program_ID:
ProgramInfoData[Num].p_ProgramID = &Array[point]; //&MXL_11[i];
ProgramInfoData[Num].len_ProgramID = len-1;
break;
case Program_Name:
ProgramInfoData[Num].p_ProgramName = &Array[point];
ProgramInfoData[Num].len_ProgramName = len-1;
default:
printf("%s\n","################case Program: 数据无效############");
break;
}
}break;
case Program_Detail:
{
switch(j)
{
case Category_Count:
CategoryInfoData[Num].p_Count = &Array[point];
CategoryInfoData[Num].len_Count = len-1;
break;
case Category_Line:
Num++;
--i; //边界问题
break;
case Category_ID:
CategoryInfoData[Num].p_CategoryID = &Array[point]; //&MXL_11[i];
CategoryInfoData[Num].len_CategoryID = len-1;
break;
case Category_Name:
CategoryInfoData[Num].p_CategoryName = &Array[point];
CategoryInfoData[Num].len_CategoryName = len-1;
default:
printf("%s\n","################case Program_Detail: 数据无效############");
break;
}
}
default:
printf("%s\n","################ (Divi: 数据无效############");
break;
}
while(--len)
{
// printf("%c",MXL_11[point]);
point++;
}
// printf("\n");
// getch();
}
}
// len=0;
j=0;
}
}
}
void insertch(char *p,char *q)
{
static int i;
for(i=strlen(q);i>0;i--)
p[i+1]=q[i];
p[1]='/';
p[0]='<';
}
void screen()
{
int i,j;
for(i=0;i<8;i++)//CategoryInfoData[0].Count
{
// printf("%d.",i);
for(j=0;j<CategoryInfoData[i].len_CategoryID;j++)
{
printf("%c",*(CategoryInfoData[i].p_CategoryID+j));
}
for(j=0;j<CategoryInfoData[i].len_CategoryName;j++)
{
printf("%c",*(CategoryInfoData[i].p_CategoryName+j));
}
printf("\n");
}
}
- 1
- 2
前往页