这样的xml如何定义存储他的数据结构?

这样的xml如何定义存储他的数据结构?

我在unix下使用c语言操作xml文件,一般我定义一个结构来存储一段xml信息:
如:

1<all>
2<stu>
3<id>1</id>
4<name></name>
5</stu>
6<stu>
7</stu>
8</all>

程序中对应的结构是:
struct typStu
{
int id;
char *name;
}

struct typAll
{
int iCnt; //Stu节点的数目
struct typStu *StuPtr; //存储各Stu信息的区域的指针,程序中根据iCnt的值动态分配
}

但是对于下面的xml信息,我就不知道如何定义数据结构进行操作了

 1<all>
 2<stu>
 3<id>1</id>
 4<name></name>
 5</stu>
 6<teacher>
 7</teacher>
 8<stu>
 9</stu>
10<teacher>
11</teacher>
12</all>

stu和Teacher中的属性是不一样的。
在xml文件中每一个标签的排列是有先后顺序的,换句话说,就是一个xml节点内有多个不同类型的标签混合排列,并且有顺序。
这种情况在程序中如何定义数据结构呢?
谢谢

---------------------------------------------------------------

in C? it is kind of tough, you might need to declare two struct's, and use a linked list inside typeAll

Published At
Categories with Web编程
Tagged with
comments powered by Disqus