iPhone SDK: XML mystery, after adding child nodeforXPath returns nothing (found a hacky solution)

我与影子孤独终老i 提交于 2019-11-29 16:27:06

Your problem is here:

<inferenceresponse xmlns="">

The empty namespace attribute is obviously confusing the libxml XPath evaluation. If you step through GDataXMLNode's nodesForXPath:namespaces:error:, xmlXPathEval indeed returns an empty nodes set.

If you have control over the XML generation, I've got correct XPath results removing the empty attribute.

<inferenceresponse>

If modifying the server response is too hard, you can edit GDataXMLNode.m: Find the method fixQualifiedNamesForNode:graftingToTreeNode: in GDataXMLNode implementation and replace the line

if (foundNS != NULL) {
    // we found a namespace, so fix the ns pointer and the local name

with

if (foundNS != NULL && foundNS->href != NULL && strlen((char *)foundNS->href) != 0) {
    // we found a namespace, so fix the ns pointer and the local name
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!