且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Cocoa向服务器发送和接收XML

更新时间:2022-06-03 22:30:15

您发布的文章看起来相当全面。你实现了三个连接委托方法?执行 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.