last day (14 days later) » 

12:22 PM
0
Q: How to post string with special character using XML parsing in objective c

MujuI am new in ios and I am facing problem regarding to post string containing special character. My code is like this in DidFinishLoading: NSXMLParser *myNSXMLParserPostObj=[[NSXMLParser alloc]initWithData:myNSMDataPostFromServer]; myNSXMLParserPostObj.delegate=self; [myNSXMLParse...

 
What is your special character, could you share (part of) your xml file with and without it? Error code 111 could indicate malformed xml file: stackoverflow.com/questions/20454853/nsxmlparsererrordomain-‌​111
 
@Koen I am adding special character as "&<>".
 
See my answer below.
 
@Koen No I directly need to pass it as it is. Because I also need to pass it in thai language.I do not want to replace string.
 
Please read this, maybe it is helpful: stackoverflow.com/questions/1091945/…
 
12:22 PM
@Koen its is not accepting &.
 
Did you try different string encodings, NSUTF8StringEncoding may not be the right one for Thai?
 
@Koen which one I need to add.
@Koen I have add NSUTF32StringEncoding nothing happen.
@Koen nothing happen
 
I don't know, I am not Thai :) I found this: stackoverflow.com/questions/2871903/…, maybe it will help. Other than that, I have no idea.
 
@Koen Is there is any way to add special character without replacing it.
@Koen I am able to access special character by using code like this
loginStatusZone = [[NSString alloc] initWithBytes: [myNSMDatazoneFromServer mutableBytes] length:[myNSMDatazoneFromServer length] encoding:NSUTF8StringEncoding];
NSLog(@"loginStatus =%@",loginStatusZone);
NSError *parseError = nil;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:loginStatusZone error:&parseError];
NSLog(@"JSON DICTIONARY = %@",xmlDictionary);
recordResultZone = [xmlDictionary[@"success"] integerValue];
NSLog(@"Success: %ld",(long)recordResultZone);
NSDictionary* Address=[xmlDictionary objectForKey:@"soap:Envelope"];
@Koen Is there is any way to post code like this
//
// XMLReader.h
//
// Created by Troy on 9/18/10.
// Copyright 2010 Troy Brant. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface XMLReader : NSObject
{
NSMutableArray *dictionaryStack;
NSMutableString *textInProgress;
NSError *errorPointer;
}

+ (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)errorPointer;
+ (NSDictionary *)dictionaryForXMLString:(NSString *)string error:(NSError **)errorPointer;

@end
//
// XMLReader.m
//
// Created by Troy on 9/18/10.
// Copyright 2010 Troy Brant. All rights reserved.
//

#import "XMLReader.h"

NSString *const kXMLReaderTextNodeKey = @"text";

@interface XMLReader (Internal)

- (id)initWithError:(NSError **)error;
- (NSDictionary *)objectWithData:(NSData *)data;

@end


@implementation XMLReader

#pragma mark -
#pragma mark Public methods

+ (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)error
{
XMLReader *reader = [[XMLReader alloc] initWithError:error];
@Koen Are you there??????
 
I'm out of ideas. Maybe someone else can help you. Good luck.
 
12:40 PM
@Koen can you please tell me how can I used CDATA in my code.
 
12:51 PM
No, I don't. I highly recommend to do some more searching on this subject. I'm sure others have run into the same issue before.
 

last day (14 days later) »