여러분 모두 도와 주셔서 미리 감사드립니다. 나는 나에게 다음과 같은 방법으로 SOAP 메시지 반환하는 웹 서비스 소모하고있어 : NSXMLParser 오류, XML 태그 내에 유효하지 않은 문자를 제거하는 방법은 무엇입니까?
이
상황이다<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getMessagesResponse xmlns="urn:DefaultNamespace">
<getMessagesReturn xmlns="">
<?xml version="1.0" encoding="ISO-8859-1" ?>
<contact>
A message with escaped values like & < >
</contact>
</getMessagesReturn>
</getMessagesResponse>
</soapenv:Body>
</soapenv:Envelope>
내가 NSUTF8StringEncoding이 getMessagesReturn 아이를 읽기 위해 사용하고 다음과 같은 저를 생성
<?xml version="1.0" encoding="ISO-8859-1">
<contact>
A message with escaped values like & < >
</contact>;
내 문제는 또한 접촉 태그 내부의 & <>를 언 이스케이프이다, 이러한 잘못된 문자가 내부에 있기 때문에 물론 NSXMLParser에서 오류가 발생합니다 XML 태그.
내 질문은 어떻게 피할 수 있습니까? 정보를 파서에 전달하기 전에 태그 메시지 내용 만 이스케이프 (escape) 할 수있는 방법이 있습니까?
도움을 주시면 감사하겠습니다.
편집 내가 사용
[NSString stringWithCString:(char*)elementText encoding:NSUTF8StringEncoding];
데이터를 UTF8로 변환하기 위해 사용하고있는 것이 무엇인지 모르겠지만 NS-apis가 엔티티를 벗어나지 않습니다. –