c语言解析xml文档(minixml):http://blog.csdn.net/shenwansangz/article/details/47358785
const char *whitespace_cb(mxml_node_t *node, int where)
{
static const char *tabs = "\t\t\t\t\t\t\t\t\t\t";
int level = 0;
int i = 0;
const char *name;
mxml_node_t *parent;
name = node->value.element.name;
char *dev = NULL;
dev = (char*)calloc(4, sizeof(char));
/*
*在schedule元素打开之前 \n+<schedule>,关闭之前 \n+</schedule>
*/
for (i = 0; i < num_xml_in_whitespace_cb; i++)
{
sprintf(dev, "Dev%d", i+1);
if (!strcmp(name, "xml") ||
!strcmp(name, dev) &&
(where == MXML_WS_BEFORE_OPEN || where == MXML_WS_BEFORE_CLOSE))
return ("\n");
}
if (!strcmp(name, "Identification") || \
!strcmp(name, "NetworkProtocols") || \
!strcmp(name, "URL") || \
!strcmp(name, "VideoEncoderConfiguration") || \
!strcmp(name, "ImagingSetting") && \
(where == MXML_WS_BEFORE_OPEN || where == MXML_WS_BEFORE_CLOSE))//|| where == MXML_WS_BEFORE_CLOSE HwAddress HTTPS
return ("\n\t");
if (!strcmp(name, "Name") ||
!strcmp(name, "Location") ||
!strcmp(name, "HwAddress") ||
!strcmp(name, "Encoding") ||
!strcmp(name, "Quality") ||
!strcmp(name, "GovLength") ||
!strcmp(name, "Brightness") ||
!strcmp(name, "ColorSaturation") ||
!strcmp(name, "Contrast") ||
!strcmp(name, "Sharpness"))
{
if (where == MXML_WS_BEFORE_OPEN)
return ("\n\t\t");
//if (where == MXML_WS_BEFORE_CLOSE) Port
// return ("\n\t\t");
}
if ((!strcmp(name, "IP4") ||
!strcmp(name, "IP6") ||
!strcmp(name, "HTTP") ||
!strcmp(name, "RTSP") ||
!strcmp(name, "HTTPS") ||
!strcmp(name, "Resolution") ||
!strcmp(name, "RateControl") ||
!strcmp(name, "Exposure")))
{
if (where == MXML_WS_BEFORE_OPEN)
return ("\n\t\t");
if (where == MXML_WS_BEFORE_CLOSE)
return ("\n\t\t");
}
if ((!strcmp(name, "DHCP") ||
!strcmp(name, "NetMask") ||
!strcmp(name, "Enabled") ||
!strcmp(name, "Port") ||
!strcmp(name, "NetworkDefaultGateway") ||
!strcmp(name, "Height") ||
!strcmp(name, "Width") ||
!strcmp(name, "BitrateLimit") ||
!strcmp(name, "EncodingInterval") ||
!strcmp(name, "FrameRateLimit") ||
!strcmp(name, "MaxExposureTime") ||
!strcmp(name, "MinExposureTime") ||
!strcmp(name, "MaxGain") ||
!strcmp(name, "MinGain")) &&
where == MXML_WS_BEFORE_OPEN)
return ("\n\t\t\t");
//if (where == MXML_WS_BEFORE_OPEN && (!strcmp(name, "FHD") || !strcmp(name, "SHD") || !strcmp(name, "MAC")))
//{
// //for (level = -1, parent = node->parent; parent; level++, parent = parent->parent);//遍历级数,打印对应的\t
// //if (level > 8)
// //level = 8;
// //else if (level < 0)
// //level = 0;
// //return (tabs + 8 - level);
// return ("\n\t\t\t");
//}
/*
* 如果不需要添加空白字符则返回NULL。
*/
return (NULL);