使用Cocoa向服务器发送和接收XML [英] Sending and receiving XML, to and from server using Cocoa
问题描述
我有一些XML数据,我想传送到网络服务器,响应也是在XML。
I have some XML data that I want to transmit to a web server and the response is also in XML.
我试图使用Cocoa解析XML 。我已遵循此文档创建XML和发送它,但是该文档不能很好地解释如何从服务器接收XML响应。
I am trying to use Cocoa to parse the XML. I have followed this document to create the XML and transmit it, but the document doesn't explain very well how you can receive the XML response from the server.
我没有找到任何好的例子使用google。有人可以指点我一些好的资源来集成XML和Cocoa吗?感谢
I haven't been able to find any good examples using google either. Can someone point me to some good resources to integrate XML and Cocoa? Thanks
推荐答案
您发布的文章看起来相当全面。你实现了三个连接委托方法?执行 transmitXMLRequest:
后, NSURLConnection 对象将自动开始加载数据。您的代理将看到以下内容:
The article that you posted looks pretty comprehensive. Did you implement the three connection delegate methods? Once you execute transmitXMLRequest:
, the NSURLConnection object will automatically start loading in data. Your delegate will see the following:
connection:didReceiveResponse:
connection:didReceiveData:
connection:didReceiveData:
connection:didReceiveData:
...
connectionDidFinishLoading:
您在每个代理方法中放置的代码至关重要。没有它,不会从服务器中检索任何数据。
The code that you place in each of those delegate methods is critical. Without it, no data is ever retreived from the server.
在第3页的文章中,将介绍如何创建 NSXMLDocument 从接收的数据。 NSXMLDocument简化了解析XML文件的过程。有关详情,请参阅Apple的基于树的XML编程指南。
In your article, on page 3, it describes how to create an NSXMLDocument from the received data. NSXMLDocument simplifies the process of parsing an XML file. For details, see Apple's Tree-Based XML Programming Guide.
这篇关于使用Cocoa向服务器发送和接收XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!