Working with spaces in XML parsing

I have a problem parsing XML.

I analyzed data from cities, Amsterdam and Den Bosch.

Amsterdam works great, but Den Bosch does not.

Undoubtedly, this is due to the space problem. Den Bosch has a space.

Should I truncate spaces in the application or in the web service?

What would be the best way to solve the problem of space?

EDIT: OP and @ PeterMurray-Rust seem to agree that the problem is that a third-party application returns strings with escaped form URLs:

"Den%20Bosch"

% 20 is not recognized by XML as anything special and that it will be necessary to replace occurrences with spaces. A typical scenario would be

s/%20/ /g

This is likely to be a fairly common problem, although I do not understand why the content should be encoded in the URL.

[OP , ]

+3
4

, :

<city>Den%20Bosch</city>

"%20" - , XML . XSLT . Java XOM

String value = cityNode.getValue().replaceAll("%20", " ");

Cocoa - , API, , .

+2

, xml , , , , "Den" "Bosch". , , -, , , -, , - . .

+1

cocoa xml. - node . , . , . CDATA,

+1
This is the code i implemented its working fine..........


if ([appDelegate.cityListArray count]>0) {
        aDJInfo=[appDelegate.cityListArray objectAtIndex:indexPath.row];
//http://compliantbox.com/party_temperature/citysearch.php?city=Amsterdam&latitude=52.366125&longitude=4.899171
        url=@"http://compliantbox.com/party_temperature/citysearch.php?city=";
        NSString *string=[aDJInfo.city_Name stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
        url=[url stringByAppendingString:string];
        NSLog(@"abbbbbbbbbbb %@",string);
        url=[url stringByAppendingString:@"&latitude=52.366125&longitude=4.899171"];
        [self parseEventName:[[NSURL alloc]initWithString:url]];
    }
}

@ .

0

Source: https://habr.com/ru/post/1783832/


All Articles