2010-06-12 5 views
0

나는 webservices를 호출하고 있습니다. 웹 서비스는 xml 형식의 데이터를 반환합니다. 이제 문제는 XML 데이터가 올바른 형식으로 수신되지 않는다는 것입니다. "<"대신 ">"은 HTML 형식으로 반환됩니다. 그래서 xmldata를 NsMutableString에 할당하고 이스케이프 문자를 바꿔서 xml 데이터 형식이 적절하도록했습니다. 그런 다음 NSData에 NSMutableString을 다시 할당하여 태그를 구문 분석 할 수 있습니다. 하지만 문제는 xmlparser가 xml 데이터가있는 곳에서 바로 멈추는 것입니다. 내가 태그를 대체 한 곳. 그것은 더 이상 가지 않습니다. 아무도 내가 무슨 일이 일어나고 있는지 이해할 수 있니?nsdata에서 nsdata로 nsstata

이것은 내가 호출 한 webservice의 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"> 
    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;customer&gt;&lt;id&gt;1&lt;/id&gt;&lt;customername&gt;Hitesh&lt;/customername&gt;&lt;phonenumber&gt;98989898&lt;/phonenumber&gt;&lt;/customer&gt; 
</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 데이터를 구문 분석하는 동안 파서는 태그를 반환 할 때까지만 이동합니다. 그리고 거기에 붙어 있습니다. 그것은 더 이상 가지 않습니다. 와트는 그렇게합니까? 나 좀 도와 줄 사람?

답변

1

어떤 파서를 사용합니까? iPhone에서 다른 파서를 사용할 수 있습니다 (예 : TouchXML 또는 TinyXML).

<?xml version="1.0" encoding="utf-8"?>도 'return'태그에서 제거하거나 다른 태그로 교체하는 것이 좋습니다. 그런 다음 필요할 때 역변환을하십시오.

+0

NSXMLParser를 사용하고 있습니다. xcode에있는 것. – Jayshree

+0

안녕하세요. 그것은 단지 문제였습니다. 응답에서 해당 태그를 제거하면 작동합니다. – Jayshree

관련 문제