我正在调用web服务。web服务以xml格式返回数据。现在的问题是xml数据没有以正确的格式接收。代替"<",">“,它以html形式返回。
因此,我将xmldata分配给一个NsMutableString,并替换了转义字符,这样xml数据的格式就正确了。然后我将NSMutableString重新分配给NSData,这样我就可以解析标签了。但问题是xmlparser正好停在xml数据所在的位置,我在此替换了标记。它不会走得更远。怎么一回事?
这是我调用的web服务的xml响应。
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:GetCustomerInfoResponse xmlns:ns1="http://aa.somewebservice.com/phpwebservice">
<return xsi:type="xsd:string">
<?xml version="1.0" encoding="utf-8"?><customer><id>1</id><customername>Hitesh</customername><phonenumber>98989898</phonenumber></customer>
</return>
</ns1:GetCustomerInfoResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>这是在我替换了标签之后。
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:GetCustomerInfoResponse xmlns:ns1="http://aa.somewebservice.com/phpwebservice">
<return xsi:type="xsd:string">
<?xml version="1.0" encoding="utf-8"?>
<customer><id>1</id><customername>Hitesh</customername><phonenumber>98989898</phonenumber></customer>
</return>
</ns1:GetCustomerInfoResponse>
</SOAP-ENV:Body></SOAP-ENV:Envelope>现在的问题是,当解析xml数据时,解析器只返回标签。然后它就卡在那里了。
发布于 2010-06-12 14:27:30
你用的是什么解析器?在iPhone上你可以使用不同的解析器(例如:TouchXML或TinyXML),试着使用它们…
另外,我认为您应该从'return‘标记中删除<?xml version="1.0" encoding="utf-8"?>,或者用另一个标记来替换它。然后在需要的时候进行反变换。
https://stackoverflow.com/questions/3027700
复制相似问题