现在的位置: 首页 > 综合 > 正文

可配置练习

2013年09月22日 ⁄ 综合 ⁄ 共 1123字 ⁄ 字号 评论关闭

 

from xml.dom import minidom
import sys
import os

try:
 xmldoc = minidom.parse("text.xml")
 print '=====xmldoc======'
except:
 print '=====SYS======'
 sys.exit(0)

for node in xmldoc.getElementsByTagName("item"):
 iditem = node.getAttribute("id")
 captionitem = node.getElementsByTagName("caption")
 for i in captionitem:
   
 
 print '==========='
 print iditem
 print captionitem
 

 

#ifndef XXX_H
#define XXX_H

extern const char *szPhone1;
extern const char *szPhone2;
extern const char *szPhone3;
extern const char *szPhone4;

typedef struct _Test Test;

typedef void(*FUNCPRINT)(const Test pData);

struct _Test
{
 int        nEnum;
 const char *szStr;
 FUNCPRINT  pFunc;
};

#endif

#include "001.h"

const char *szPhone1 = "/phone/one";
const char *szPhone2 = "/phone/two";
const char *szPhone3 = "/phone/three";
const char *szPhone4 = "/phone/four";

 

#include <stdio.h>
#include "001.h"

static void GOPrintf(const Test pData)
{
 printf("[%d]:%s\n", pData.nEnum, pData.szStr);
}

static const Test m_szTest[] =
{
 {1, szPhone1, GOPrintf},
 {2, szPhone2, GOPrintf},
 {3, szPhone3, GOPrintf},
 {4, szPhone4, GOPrintf},
};

int main()
{
 int i      = 0;
 int nCount = 0;

 nCount = sizeof(m_szTest)/sizeof(Test);

 for (i = 0; i < nCount; i++)
 {
  (*m_szTest[i].pFunc)(m_szTest[i]);
 }

}

 

 

 

 

抱歉!评论已关闭.