Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to parse CData #35

Open
dwijsoft-dipen opened this issue Apr 20, 2015 · 2 comments
Open

Fail to parse CData #35

dwijsoft-dipen opened this issue Apr 20, 2015 · 2 comments

Comments

@dwijsoft-dipen
Copy link

My xml contains data as below.

When it tries to parse that data it great the queue return the data till that part.

@gabebear
Copy link

Not sure if this is what you are coming up against, but Apple's XML parser vomits when certain characters are fed to it. What we are doing to protect our app is strip them before sending the data into XMLDictionary/NSXMLParser.

NSMutableString *dataString = [[NSMutableString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//This expression matches several control characters including all Information Separators
NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:@"&#x?[0-8,b,c,e,f];|&#1[1-2,4-9];|&#x1[0-9,a-f];|&#2[0-9];|&#3[0,1];"
                                                                    options:0
                                                                      error:NULL];
[expression replaceMatchesInString:dataString
                   options:0
                     range:NSMakeRange(0, dataString.length)
              withTemplate:@""];
NSData *filteredData = [dataString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
xmlDict = [newParser dictionaryWithData:filteredData];

Can you run the XML through NSXMLParser at all?

@dwijsoft-dipen
Copy link
Author

yes i tried that it seems it is also breaking from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants