当我使用:
时,我得到了以下回应NSString *jobSearchUrlString = [NSString stringWithFormat:@"http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries"];
NSLog(@"url for new articles is = %@",jobSearchUrlString);
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:jobSearchUrlString]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
if( request )
{
RoutData = [[NSMutableData alloc] init];
}
else
{
NSLog(@"RoutConnection is NULL");
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[RoutData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[RoutData appendData:data];
NSString *thexml = [[NSString alloc] initWithData:RoutData encoding:NSUTF8StringEncoding];
NSLog(@">>>>>>>>>> laxman Route data <<<<<<<<<<<<<<<<< %@",thexml);
xmlParser = [[NSXMLParser alloc] initWithData: RoutData];
[xmlParser setDelegate: self];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];
result = [soapResults dataUsingEncoding:NSUTF8StringEncoding];
webdataParser = [[NSXMLParser alloc]initWithData:result];
[webdataParser setDelegate:self];
[webdataParser setShouldResolveExternalEntities:YES];
[webdataParser parse];
NSLog(@"---------->>>>>>>><<<<<<<<<<<--------- %@",resultData);
<xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Countries</title>
<id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries</id>
<updated>2012-02-25T09:36:30Z</updated>
<link rel="self" title="Countries" href="Countries" />
<entry>
<id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries(14)</id>
<title type="text"></title>
<updated>2012-02-25T09:36:30Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Country" href="Countries(14)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" type="application/atom+xml;type=entry" title="Region" href="Countries(14)/Region" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Contact_
2012-02-25 15:06:29.393 SampleTest[335:f803] ---------->>>>>>>><<<<<<<<<<<--------- (null)
2012-02-25 15:06:29.395 SampleTest[335:f803] >>>>>>>>>> laxman Route data <<<<<<<<<<<<<<<<< <?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Countries</title>
<id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries</id>
<updated>2012-02-25T09:36:30Z</updated>
<link rel="self" title="Countries" href="Countries" />
<entry>
<id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries(14)</id>
<title type="text"></title>
<updated>2012-02-25T09:36:30Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Country" href="Countries(14)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" type="application/atom+xml;type=entry" title="Region" href="Countries(14)/Region" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Contact_Country" type="application/atom+xml;type=feed" title="Contact_Country" href="Countries(14)/Contact_Country" />
<category term="HpSalesPortalMobileDBModel.Country" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int16">14</d:Id>
<d:RegionId m:type="Edm.Byte">1</d:RegionId>
<d:CountryName>France</d:CountryName>
</m:properties>
</content>
</entry>
<entry>
<id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries(15)</id>
<title type="text"></title>
<updated>2012-02-25T09:36:30Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Country" href="Countries(15)" />
如何解析数据以获得&#34; Id&#34;,&#34; RegionId&#34;和&#34; CountryName&#34;?
有没有办法解析一个元素的数据?
答案 0 :(得分:1)
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
//U can Catch Ur data in this delegate And Set Condition Get data Witch U Want.
}