[英]how to read webService from server using Xcode?
![I tried to read xml file using Xcode but it give response in String and xml will show like in following image and it give < and > behalf of < and >][1] ![[我尝试使用Xcode读取xml文件,但是它在String中给出了响应,并且xml将如下图所示,并且它给出<和>代表<和>] [1]
I am trying to read mywebservice from server. 我正在尝试从服务器读取mywebservice。 i wrote web service which create file in xml formate in website. 我写了Web服务,该服务在网站的xml formate中创建文件。 when i check that file on website uing internet it shows like following: 当我使用互联网检查网站上的文件时,它显示如下:
<NewDataSet>
<Table>
<Column1>Audi</Column1>
</Table>
<Table>
<Column1>BMW</Column1>
</Table>
<Table>
<Column1>MINI</Column1>
</Table>
</NewDataSet>
but when i call that file via soap it gives response in following: 但是当我通过肥皂调用该文件时,它会在以下响应中给出:
<NewDataSet>
<Table>
<Column1>Audi</Column1>
</Table>
<Table>
<Column1>BMW</Column1>
</Table>
<Table>
<Column1>MINI</Column1>
</Table>
</NewDataSet>
but i can't read the tag like 'NewDataSet' because it give back response in String and i am new in XML so please help me.. i use Xcode and nsmutabledata for that..!! 但我无法读取“ NewDataSet”之类的标签,因为它会在String中返回响应并且我是XML的新用户,所以请帮助我..我为此使用Xcode和nsmutabledata。 i tried stringbyReplaceofOccurance but it did not replace < and > with < >. 我尝试使用stringbyReplaceofOccurance,但是它没有用<>替换&lt和&gt。 Thanks in Advance. 提前致谢。
Thanks in advance for helping. 在此先感谢您的帮助。
I think, try NSXMLParser 我认为,请尝试NSXMLParser
this might be helpful for you... 这可能对您有帮助...
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
you use best way of read xml file with TouchXML ....and for TouchXML use this bellow link 您可以使用使用TouchXML ....读取XML文件的最佳方法,而对于TouchXML使用此波纹管链接
http://dblog.com.au/general/iphone-sdk-tutorial-building-an-advanced-rss ... http://dblog.com.au/general/iphone-sdk-tutorial-building-an-advanced-rss ...
also here when you get response then other way you can read like bellow using TouchXML.. ie.. 同样在这里,当您获得响应时,则可以使用TouchXML像下面这样以其他方式阅读..即
- (void) fetchDataSuccessforEvent:(NSMutableData *)data
{
CXMLDocument *doc = [[[CXMLDocument alloc] initWithData:data options:0 error:nil] autorelease];
NSArray *nodes = [doc nodesForXPath:@"//Table" error:nil];
for (CXMLElement *node in nodes)
{
for(int counter = 0; counter < [node childCount]; counter++)
{
if ([[[node childAtIndex:counter] name] isEqualToString:@"Column1"])
{
NSString *string = [[node childAtIndex:counter] stringValue];
NSLog(@"\n\n Title %@",string);
}
}
}
}
so easy... hope,this help you.... :) 非常容易...希望,对您有帮助。...:)
This is not a parsing problem. 这不是解析问题。 Check the web service and make sure that xml header is: <?xml version="1.0" encoding="utf-8"?>
or something like this. 检查Web服务,并确保xml标头为: <?xml version="1.0" encoding="utf-8"?>
或类似的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.