Today 4.18

今天终于搞懂 XML_SetCharacterDataHandler(p, char_hndl);

void
char_hndl(void *data, const char *txt, int txtlen)是怎么回事了:原来Expat处理的时候,每当遇到
空格、回车、'/t'都会调用 char_hndl(),而且所说的txt指针指向的字串是没有结束标记'/0'的,txt指向XML_Parse(p, Buff, len, done)没有处理完的字符串,txtlen用于说明一次调用char_hndl() 所应该处理的字符串长度,所以要想正确获得txt中的数据,应该注意处理空格、回车、'/t'等等。

从中看出英语水平有待提高,因为Clark Cooper 在http://www.xml.com/pub/a/1999/09/expat/index.html?page=3#chardatahandler写到:

XML_SetCharacterDataHandler
XML_SetCharacterDataHandler(XML_Parser p,
                            XML_CharacterDataHandler charhndl)
typedef void
(*XML_CharacterDataHandler)(void *userData,
                            const XML_Char *s,
                            int len);

Set a text handler. The string your handler receives is NOT zero terminated. You have to use the length argument to deal with the end of the string. A single block of contiguous text free of markup may still result in a sequence of calls to this handler. In other words, if you're searching for a pattern in the text, it may be split across calls to this handler.

已经讲得很清楚了。

计划明天写XML处理的相关函数。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值