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

前端 未结 1 779
时光取名叫无心
时光取名叫无心 2020-12-21 21:13

I have a big mystery here,

I have a Gdataxml document property:

GDataXMLDocument *doc;

I\'m adding a new element to doc, interestin

相关标签:
1条回答
  • 2020-12-21 21:43

    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
    
    0 讨论(0)
提交回复
热议问题