gpt4 book ai didi

iphone - 得到响应后如何使用json解析器解析数据?

转载 作者:行者123 更新时间:2023-11-29 04:47:15 24 4
gpt4 key购买 nike

当我使用时,我收到以下响应:

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)" />

如何解析数据以获取“Id”、“RegionId”和“CountryName”?

有没有一种方法可以解析一个元素的数据?

最佳答案

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string 
{
//U can Catch Ur data in this delegate And Set Condition Get data Witch U Want.
}

关于iphone - 得到响应后如何使用json解析器解析数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9442997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com