php下通过xml_parse解析xml文件

xml_parse解析xml文件时候,

很有可能不仅仅调用一次character_handler。

所以在获得xml节点的文本信息的时候,要用连接运算".="。

 

参考 http://jp2.php.net/manual/ro/function.xml-set-character-data-handler.php

 

ken at positive-edge dot com
30-Jan-2002 01:20
the function handler is called several times when it parses the character data.  It doesn't return the entire string as it suggests.  There are special exceptions that will always force the parser to stop scanning and call the character data handler.  This is when:

- The parser runs into an Entity Declaration, such as & (&) or ' (�)
- The parser finishes parsing an entity
- The parser runs into the new-line character (/n)
- The parser runs into a series of tab characters (/t)

And perhaps others.

For instance, if we have this xml content:

<mytag name=�Ken Egervari� title=�Chief Technology Officer�>
    Ken has been Positive Edge&apos;s Chief Technology Officer for 2 years.
</mytag>

The parser will call the character data handler 6 times.  This is what will happen:

1    /n
2    /t
3    Ken has been Positive Edge
4    �
5    s Chief Technology Officer for 2 years.
6    /n

I hope that helps people out.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值