Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6341627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:04:30+00:00 2026-05-24T20:04:30+00:00

I have a big mystery here, I have a Gdataxml document property: GDataXMLDocument *doc;

  • 0

I have a big mystery here,

I have a Gdataxml document property:

GDataXMLDocument *doc;

I’m adding a new element to doc, interestingly, this method below looks perfect for other elements but not for the element I just added:

GDataXMLElement *newValueDefElement = [GDataXMLNode elementWithName:@"valuedefinition"];
[variableElement addChild:newValueDefElement];

and now when I query:

NSString *path = [NSString stringWithFormat:@"//inferenceresponse/state/variable[pageId=%d]/valuedefinition",pageID];       
NSArray *valueElement = [self.doc nodesForXPath:path error:nil];

Now array comes with zero objects! new added element NOT found! but I can see it in debug as xml string, how on earth it can not find something which I can see it is there on the log? it is a cache problem or a namespace problem or a bug in GDataXML? again..Problem is adding a new child and it is somehow not updated in the doc, but I can get the other elements under same root when use the same Xpath query standard

in NSlog I can see that the new element is added to doc.

NSData *xmlData2 = self.doc.XMLData;
NSString *s= [[[NSString alloc] initWithBytes:[xmlData2 bytes] length:[xmlData2 length] encoding:NSUTF8StringEncoding] autorelease];
NSLog(s);

Also How can self.doc.XMLData give something different than [self.doc nodesForXPath]? so it fools me to thing my doc is ok but maybe I corrupted the doc or a wrong namespace while adding removing some elements in a previous method?

my xml starts like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<inferenceresponse xmlns="">
<state goalreached="false">
..
..

Update

I just found a (hacky) solution; when I convert “doc” to NSData with “doc.XMLData” and then again convert back to doc, then it works! but this should not be real solution, that’s lame to do that conversion back and forth to get a correct document object. What is the problem here? I guess it can not fix the namespaces for new child.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:04:31+00:00Added an answer on May 24, 2026 at 8:04 pm

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have big element at the top of the webpage that sides down with
I'm new to Jira and have big problem with creating tables inside my testing
I have big content. get by file_get_content. It like this: <div class=nwsdetail> <div class=othernws>
I have big problems. I'm new on a small company and now I'm in
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
I have big system that make my system crash hard. When I boot up,
I have big URL list, which I have to download in parallel and check
I have big trouble with file uploads with php. My own tests are successful
I have big problem when I am trying to deploy my app over clickonce.
I really have big problems with importing an extern C-Library to my existing C++-Project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.