我想将包含xml代码的NSString变量转换为xml格式。我的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>
        <Authentication xmlns="(namespace link)">
            <Credentials>
                    <Username>username</Username>
                    <Password>password</Password>
            </Credentials>
        </Authentication>
</soapenv:Body>
</soapenv:Envelope>

然后我将此请求保存到NSString变量。由于服务器无法识别为xml,因此我对此做出了回应。那么如何将我保存的字符串转换为xml?

最佳答案

SOAP请求和解析的简单代码。
转到链接:https://yuvarajmanickam.wordpress.com/2012/10/17/soap-message-request-and-xmlparsing-in-ios-app/
github.com/nicklockwood/XMLDictionary
stackoverflow.com/questions/803676/encode-nsstring-for-xml-html

10-08 07:53