Archived Forum Post

Index of archived forum posts

Question:

Possible regression in 9.4.1.42: CkoXml SearchForTag:tag: (Objective-C)

Sep 05 '13 at 19:32

I updated to 9.4.1.42 today and have a strange regression. I've been using CkoXml to parse the errorXml property that comes out of the other Chilkat methods. This is my code:

CkoXml *foundXML = nil;
NSMutableString *errorString = [NSMutableString stringWithCapacity:10];
int raceLimiter = 1;
do {
    foundXML = [coreErrorXML SearchForTag:foundXML tag:@"error"];
        if (foundXML) {
            [errorString appendFormat:@"%@\n", foundXML.Content];
        }
raceLimiter ++;
} while (foundXML && raceLimiter < 1000);

Under 9.3.1 (what I was using), I would get something like:

Failed. Failed to receive data on the TCP socket Failed to get initial SMTP response.. Failed to receive data on the TCP socket Failed to get initial SMTP response again.

Under 9.4.1.42, I am getting an empty string. Putting a logging line in, it appears that if(foundXML) is never true. The XML coming out of the method (in this case, the smtp method) looks similar so I don't think it's bad input.

Thoughts?


Answer

Thanks. I understand the problem and I'll explain a workaround. However, first things first...

1) The error message that contains information about TCP sockets and SMTP must not have come from the XML object. I suspect you're mistakenly looking at the contents of the LastErrorText on a different object instance -- which would certainly be the MailMan object if it involves SMTP. The XML object has nothing to do with TCP sockets or SMTP...

2) Whenever a Chilkat object is passed as an argument, it should never be nil. The only exception to this case is with the XML Search* methods. The latest version (v9.4.1 at the time of this writing) does a check to see if the input argument is nil, and if so, then immediately fails (returns a failed status, or nil, etc.) without actually calling the underlying method. Because the outermost Objective-C layer is generated, this check happens cases where the argument is a pointer to a Chilkat object (to prevent a crash). However, the XML Search methods shouldn't have followed this behavior, and this is what needs to be fixed in Chilkat v9.4.1.

In any XML Search* method, the first argument indicates the node that is the root of the subtree to be searched. If nil is passed, the behavior is to search the entire XML document from the topmost root. As a workaround, instead of passing nil, one can pass [xml GetRoot] because the GetRoot method returns the root node of the XML document. Therefore, do this to get around the problem:

foundXML = [coreErrorXML SearchForTag:[coreErrorXML GetRoot] tag:@"error"];

Answer

Thanks. I'll test your workaround and report back.

Just to clarify, the output was from the mailman object. It had an (expected - I was running tests) error and I was parsing it for the 'human readable' version of the lasterrorxml (just the 'error' tags). I don't want to dump all of the error text, just some indication of what went wrong.