- 论坛徽章:
- 0
|
本帖最后由 hbmhalley 于 2012-12-01 12:02 编辑
正在试验 libxml 解析 html
例如
<p prop1="p1value">content</p>
xmlNodePtr cur_node 指向这个 node
xmlAttrPtr cur_attr = cur_node->properties
cur_attr->name == "prop1"
xmlGetProp (cur_node , "prop1") == "p1value"
但显然, 不能通过 cur_attr 直接获取 "p1value" 是无比蛋疼之事
于是翻手册,发现在 struct _xmlAttr 里 确有 "the value of the property"
可是,其类型却是
struct _xmlNode *children : the value of the property
经试验,若 cur_attr->children != NULL , 那么 cur_attr->children->content 的确可以获得 "p1value"
但实在费解,为什么要把一个 property 的 value 搞成 xmlNode 类型?
还是说,我的方法本身就有问题,只不过凑巧得到了正确的结果?
tks. |
|