代码之家  ›  专栏  ›  技术社区  ›  Yama

如何在目标C中获取简单数组格式的XML代码?

  •  1
  • Yama  · 技术社区  · 15 年前

    我只是个iPhone开发的初学者,现在我正在开发一个Facebook应用程序。问题是,我需要从WebService获取数据,其中数据的格式如下:

    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Body>
    
    <abc1>string</abc1>
    <abc2>string</abc2>
    <abc3>string</abc3>
    
    </soap:Body>
    </soap:Envelope>
    

    有人能帮我吗??

    提前谢谢。

    2 回复  |  直到 14 年前
        1
  •  2
  •   vodkhang    15 年前

    你可以试着用 TouchXML

    CXMLDocument *theXMLDocument = [[[CXMLDocument alloc] initWithXMLString:yourXMLString options:0 error:&theError] autorelease]; 
    
    NSArray *theNodes = NULL;
    
    theNodes = [theXMLDocument nodesForXPath:@"//root" error:&theError];
    for (CXMLElement *theElement in theNodes)
    {
       theNodes = [theElement nodesForXPath:@"./abc" error:NULL];
       NSLog(@"%@", theNodes);
    }
    
        2
  •  0
  •   Akash Kava    14 年前

    免责声明:我将推荐我自己公司的产品,但对于这个问题它是一个很好的建议。

    你为什么不试试网络服务连接工具呢?

    KSOAP WSCLITENT+++等