I'm using Sudzc to parse a soap XML.
I'm setting up:
amount.currency = #"BRL";
It gives me the following error:
validation 138 Unsupported currency specified
logcat:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>validation 138 Unsupported currency specified</faultstring></soap:Fault></soap:Body></soap:Envelope>
I know that the wsdl is good. So Where should I look to find this error?
SDZPayment* service = [SDZPayment service];
service.logging = YES;
service.username = #"**************";
service.password = #"****************";
SDZAmount *amount = [SDZAmount new];
amount.value = (long)100;
amount.currency = #"BRL";
SDZCard *card = [SDZCard new];
card.cvc = #"412";
card.number = #"21432423423";
card.holderName = #"Marcus Ataide";
card.expiryMonth = #"12";
card.expiryYear = #"2017";
card.brand = #"visa";
card.issueNumber = #"10";
card.startMonth = #"10";
card.startYear = #"2010";
SDZPaymentRequest *payment = [SDZPaymentRequest new];
payment.amount = amount;
payment.card = card;
payment.merchantAccount = #"*************";
payment.shopperReference = #"123456";
// Returns SDZPaymentResult*
/* */
[service authorise:self action:#selector(authoriseHandler:) paymentRequest: payment];
From web service:
<xsd:complexType name="Amount">
<xsd:sequence>
<xsd:element minOccurs="1" name="currency">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="3"/>
<xsd:maxLength value="3"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element minOccurs="1" name="value" type="xsd:long"/>
</xsd:sequence>
</xsd:complexType>
The problem was with namespace:
Inside, "SDZAmount.m", I need to change:
[s appendString: [Soap serialize: self.currency]];
to:
[s appendFormat: #"<currency xmlns=\"http://common.services.adyen.com\">%#</currency>", [Soap serialize: self.currency]];
Related
I am using raptureXML to extract data from my XML <forecast .../> tags.
This is the XML
<?xml version="1.0" ?>
<weatherdata>
<weather weatherlocationname="Chicago, IL">
<forecast low="67" high="86" skycodeday="34" skytextday="Mostly Sunny" date="2012-08-27" day="Monday" shortday="Mon" precip="0" />
<forecast low="66" high="82" skycodeday="34" skytextday="Mostly Sunny" date="2012-08-28" day="Tuesday" shortday="Tue" precip="0" />
<forecast low="66" high="82" skycodeday="34" skytextday="Mostly Sunny" date="2012-08-29" day="Wednesday" shortday="Wed" precip="0" />
<forecast low="68" high="88" skycodeday="32" skytextday="Sunny (Clear)" date="2012-08-30" day="Thursday" shortday="Thu" precip="0" />
<forecast low="70" high="90" skycodeday="34" skytextday="Mostly Sunny" date="2012-08-31" day="Friday" shortday="Fri" precip="0" />
<toolbar timewindow="60" minversion="1.0.1965.0" />
</weather>
</weatherdata>
I use this code for raptureXML
RXMLElement *rootXML = [RXMLElement elementFromXMLString:XML encoding:NSUTF8StringEncoding];
[rootXML iterate:#"forecast" usingBlock:^(RXMLElement *element)
{
NSString *high = [element attribute:#"low"];
NSLog(#"high: %#", high);
}];
NSArray *forecast = [rootXML children:#"forecast"];
NSLog(#"[forecast count]: %d", [forecast count]);
Pretty straight forward right? but the problem is that it finds NO forecast tags i.e. I get nothing for the NSLog(#"high: %#", high); and [forecast count] is Zero.
what did I miss?
I haven't used RaptureXML, but it looks like you missed a layer. rootXML is probably the weatherdata so it has no forecast children, because its only child is weather which does have forecast children. Try adding:
RXMLElement *weather = [rootXML child:#"weather"];
Then use weather for the rest of the code instead of rootXML.
Like so:
RXMLElement *rootXML = [RXMLElement elementFromXMLString:XML encoding:NSUTF8StringEncoding];
RXMLElement *weather = [rootXML child:#"weather"];
[weather iterate:#"forecast" usingBlock:^(RXMLElement *element)
{
NSString *high = [element attribute:#"low"];
NSLog(#"high: %#", high);
}];
NSArray *forecast = [weather children:#"forecast"];
NSLog(#"[forecast count]: %d", [forecast count]);
I am a .Net programmer and a beginner in Xcode. I want to display the result from a WCF service on the iPad in UITableViewController. I have successfully created stubs for the service by using wsdl2objc. The SOAP message created is as follows:
2012-07-25 14:02:37.169 TestWCF[5280:fb03] OutputHeaders:
{
"Content-Length" = 572;
"Content-Type" = "text/xml; charset=utf-8";
Host = "XXX.XXX.XXX";
SOAPAction = "http://tempuri.org/IDocSync/getAllCategories";
"User-Agent" = wsdl2objc;
}
2012-07-25 14:02:37.172 TestWCF[5280:fb03] OutputBody:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:iPadDocSyncServiceSvc="http://tempuri.org/" xmlns:ns1="http://tempuri.org/Imports" xmlns:tns1="http://schemas.datacontract.org/2004/07/DocSyncService" xmlns:tns2="http://schemas.microsoft.com/2003/10/Serialization/" xsl:version="1.0">
<soap:Body>
<iPadDocSyncServiceSvc:getAllCategories/>
</soap:Body>
</soap:Envelope>
2012-07-25 14:03:03.119 TestWCF[5280:fb03] ResponseStatus: 200
2012-07-25 14:03:03.120 TestWCF[5280:fb03] ResponseHeaders:
{
"Cache-Control" = private;
"Content-Encoding" = gzip;
"Content-Length" = 421;
"Content-Type" = "text/xml; charset=utf-8";
Date = "Wed, 25 Jul 2012 06:03:02 GMT";
Server = "Microsoft-IIS/7.5";
"Set-Cookie" = "ASP.NET_SessionId=55w4noiub50zqtqclwdx3ral; path=/; HttpOnly";
Vary = "Accept-Encoding";
"X-AspNet-Version" = "4.0.30319";
"X-Powered-By" = "ASP.NET";
}
2012-07-25 14:03:03.121 TestWCF[5280:fb03] ResponseBody:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<getAllCategoriesResponse xmlns="http://tempuri.org/">
<getAllCategoriesResult xmlns:a="http://schemas.datacontract.org/2004/07/DocSyncService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Category>
<a:categoryId>4</a:categoryId>
<a:categoryName>IT</a:categoryName>
<a:categoryType>0</a:categoryType>
<a:docCount>3</a:docCount>
<a:subCategoryId>0</a:subCategoryId>
</a:Category>
<a:Category>
<a:categoryId>6</a:categoryId>
<a:categoryName>CPG</a:categoryName>
<a:categoryType>0</a:categoryType>
<a:docCount>1</a:docCount>
<a:subCategoryId>0</a:subCategoryId>
</a:Category>
</getAllCategoriesResult>
</getAllCategoriesResponse>
</s:Body>
</s:Envelope>
The code in Appdelegate.m is:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
BasicHttpBinding_IDocSyncBinding *myBinding = [iPadDocSyncServiceSvc BasicHttpBinding_IDocSyncBinding];
myBinding.logXMLInOut = YES;
//iPadDocSyncServiceSvc_getAllCategories *allCate = [[iPadDocSyncServiceSvc_getAllCategories new]autorelease];
iPadDocSyncServiceSvc_getAllCategories *allCate = [[iPadDocSyncServiceSvc_getAllCategories alloc]init];
BasicHttpBinding_IDocSyncBindingResponse *response = [myBinding getAllCategoriesUsingParameters:allCate];
for(id bodyPart in response.bodyParts)
{
//if([bodyPart isKindOfClass:[BasicHttpBinding_IDocSyncBindingResponse class]])
//{
//tns1_ArrayOfCategory *cateClass = (tns1_ArrayOfCategory *) bodyPart;
//[self.tableView reloadData];
//categories = (NSMutableArray *) cateClass;
//tns1_ArrayOfCategory *cateClass = [bodyPart getAllCategoriesResult];
self.categories = (NSMutableArray *) [bodyPart getAllCategoriesResult];
//}
}
return YES;
}
When I run this,nothing is displayed in the Simulator...it shows a blank screen. There is something very obvious that I am missing. How can I get it working?
I wrote a few tutorials using Wsdl2Objc a while back; maybe they can help.
http://brismith66.blogspot.com/search/label/iPhone%20Development
I am trying to parse xml using the touchXML library but not getting the results, the code is as below
NSError *error = nil;
CXMLDocument *xmlParser = [[CXMLDocument alloc] initWithXMLString:dataString options:0 error:&error];
NSArray *resultNodes = NULL;
resultNodes = [xmlParser nodesForXPath:#"//entry" error:&error];
for (CXMLElement *resultElement in resultNodes) {
NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];
int counter;
for(counter = 0; counter < [resultElement childCount]; counter++) {
[blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
}
}
the method nodesForXPath: doesn't returns anything leaving the resultNodes array with 0 objects. I am getting the proper xml in dataString and the CXMLDocument is also getting prepared properly. I tried debugging it but there is nothing I can see accept the 0 objects in resultNodes, NSError also contains nothing (i.e. no error occurs). the xml file I am trying to parse is as below.
<feed xmlns:s="http://syndication.nhschoices.nhs.uk/services" xmlns="http://www.w3.org/2005/Atom">
<title type="text">...</title>
<id>...</id>
<rights type="text">© Crown Copyright 2009</rights>
<updated>2012-04-27T11:33:02+01:00</updated>
<category term="Search"/>
<logo>...</logo>
<author>...</author>
<s:SearchCoords>174900,517900</s:SearchCoords>
<entry>
<id>
http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/32248
</id>
<title type="text">Sayer A</title>
<updated>2012-04-27T10:33:02Z</updated>
<link rel="self" title="Sayer A" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/32248?apikey=YAHUGHET"/>
<link rel="alternate" title="Sayer A" href="http://www.nhs.uk/ServiceDirectories/Pages/GP.aspx?pid=15F37AEF-EC5B-4A90-9E72-269ADEB39629"/>
<content type="application/xml">
<s:organisationSummary>
<s:name>Sayer A</s:name>
<s:address>
<s:addressLine>The Richmond Green Medical Cen</s:addressLine>
<s:addressLine>19 The Green</s:addressLine>
<s:addressLine>Richmond</s:addressLine>
<s:addressLine>Surrey</s:addressLine>
<s:postcode>TW91PX</s:postcode>
</s:address>
<s:contact type="General">
<s:telephone>020 83327515</s:telephone>
</s:contact>
<s:geographicCoordinates>
<s:northing>174900</s:northing>
<s:easting>517800</s:easting>
<s:longitude>-0.305512266736965</s:longitude>
<s:latitude>51.4608026642546</s:latitude>
</s:geographicCoordinates>
<s:Distance>0.1</s:Distance>
</s:organisationSummary>
</content>
</entry>
<entry>
<id>
http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/33420
</id>
<title type="text">Griffiths W</title>
<updated>2012-04-27T10:33:02Z</updated>
<link rel="self" title="Griffiths W" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/33420?apikey=YAHUGHET"/>
<link rel="alternate" title="Griffiths W" href="http://www.nhs.uk/ServiceDirectories/Pages/GP.aspx?pid=EEC98A8A-B888-4F44-A0B6-DC6ABCBF19CE"/>
<content type="application/xml">
<s:organisationSummary>
<s:name>Griffiths W</s:name>
<s:address>
<s:addressLine>Paradise Road Surgery</s:addressLine>
<s:addressLine>37 Paradise Road</s:addressLine>
<s:addressLine>Richmond</s:addressLine>
<s:addressLine>Surrey</s:addressLine>
<s:postcode>TW91SA</s:postcode>
</s:address>
<s:contact type="General">
<s:telephone>020 89402423</s:telephone>
</s:contact>
<s:geographicCoordinates>
<s:northing>174800</s:northing>
<s:easting>518100</s:easting>
<s:longitude>-0.301388352909701</s:longitude>
<s:latitude>51.4601120315006</s:latitude>
</s:geographicCoordinates>
<s:Distance>0.223606797749979</s:Distance>
</s:organisationSummary>
</content>
</entry>
<entry>
<id>
http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/33035
</id>
<title type="text">Dr Da Costa</title>
<updated>2012-04-27T10:33:02Z</updated>
<link rel="self" title="Dr Da Costa" href="http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/33035?apikey=YAHUGHET"/>
<link rel="alternate" title="Dr Da Costa" href="http://www.nhs.uk/ServiceDirectories/Pages/GP.aspx?pid=EDCE215D-6412-4AAB-AFC4-9F37888D413C"/>
<content type="application/xml">
<s:organisationSummary>
<s:name>Dr Da Costa</s:name>
<s:address>
<s:addressLine>The Vineyard Surgery</s:addressLine>
<s:addressLine>35 The Vineyard</s:addressLine>
<s:addressLine>Richmond</s:addressLine>
<s:addressLine>Surrey</s:addressLine>
<s:postcode>TW106PP</s:postcode>
</s:address>
<s:contact type="General">
<s:telephone>020 89480404</s:telephone>
</s:contact>
<s:geographicCoordinates>
<s:northing>174600</s:northing>
<s:easting>518100</s:easting>
<s:longitude>-0.301044685875553</s:longitude>
<s:latitude>51.4581333717098</s:latitude>
</s:geographicCoordinates>
<s:Distance>0.360555127546399</s:Distance>
</s:organisationSummary>
</content>
</entry>
I've never worked with touchXML, but it may be that you need to set your namespace, like here: Getting the value of an Element in Cocoa using TouchXML
Just check out this , I was able to parse the similar kind of response :
- (void)viewDidLoad
{
[super viewDidLoad];
self.rqst=[[WebRqst alloc] init];
[self.rqst startLoading:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:#"PASS UR URL"]]
vCtr:self];
}
**// a method to grab the attributes.**
- (void)parseAttributesForElement:(CXMLElement*)element andDictionary:(NSMutableDictionary*)dictionary {
NSString *strName,*strValue;
NSArray *arAttributes = [(CXMLElement*)element attributes];
for (int i=0; i<arAttributes.count; i++) {
strName = [[arAttributes objectAtIndex:i] name];
strValue = [[arAttributes objectAtIndex:i] stringValue];
if(strName && strValue && [strName length]>0 && [strValue length]>0) {
[dictionary setValue:strValue forKey:strName];
}
}
}
**// a method to parse the node & store in dictionary**
- (void)parseThisNode:(CXMLNode*)node storeInDictionary:(NSMutableDictionary*)dOfNode {
NSString *strName = [node name];
NSString *strValue = [node stringValue];
if(strName && [strName length]>0 && ![strName isEqualToString:#"text"]) {
NSMutableDictionary *dOfAttributes = [NSMutableDictionary dictionary];
// if node has value
if(strValue && [strValue length]>0) {
[dOfAttributes setValue:strValue forKey:#"value"];
}
// if node has attributes
if([node isKindOfClass:[CXMLElement class]] && [(CXMLElement*)node attributes].count>0) {
[self parseAttributesForElement:(CXMLElement*)node andDictionary:dOfAttributes];
}
// if node has childs
NSArray *arChildern = [node children];
if(arChildern.count>0) {
NSMutableDictionary *dOfTAG=[NSMutableDictionary dictionary];
for (CXMLNode *nodeChildChild in arChildern) {
// recursive call of a function
[self parseThisNode:nodeChildChild storeInDictionary:dOfTAG];
}
if([[dOfTAG allKeys] count]>0) [dOfAttributes setValue:dOfTAG forKey:#"child"];
}
id valueFK = [dOfNode valueForKey:strName];
// verify if same node is repeated, add it to array (e.g. link tag is repeated )
if([valueFK isKindOfClass:[NSMutableArray class]]) {
NSMutableArray *ar=(NSMutableArray*)valueFK;
[ar addObject:dOfAttributes];
[dOfNode setValue:ar forKey:strName];
} else if([valueFK isKindOfClass:[NSMutableDictionary class]]) {
NSMutableArray *ar=[NSMutableArray arrayWithObjects:valueFK,dOfAttributes, nil];
[dOfNode setValue:ar forKey:strName];
} else {
[dOfNode setValue:dOfAttributes forKey:strName];
}
}
}
**// pass the data to this method & it will return a dictionary**
- (NSDictionary *)startParsingUsingData:(NSData *) data {
// create a mutable-empty dictionary wich will hold the data
NSMutableDictionary *dictionaryParsed = [NSMutableDictionary dictionary];
// verify - do we have proper data for parsing or not
if(data && [data length]>0) {
// load a data into XML Document
CXMLDocument *doc = [[CXMLDocument alloc] initWithData:data options:0 error:nil];
// grab all the tags of XML
NSArray *nodes = [doc nodesForXPath:#"*" error:nil];
// start a loop to goThrough each tag of xml
for (CXMLNode *nodeFeed in nodes) {
// verify that you reached to desired tag or not
if([[nodeFeed name] isEqualToString:#"feed"]) {
// just write this code to get data parsed & stored in our dictionary
[self parseThisNode:nodeFeed storeInDictionary:dictionaryParsed];
// grab the childrens of tag ( as per requirement )
dictionaryParsed=[[dictionaryParsed valueForKey:#"feed"] valueForKey:#"child"];
}
}
}
// return the dictionary.
if([[dictionaryParsed allKeys]count]>0) {
return [NSDictionary dictionaryWithDictionary:dictionaryParsed];
} else {
return nil;
}
}
// It's my delegate method where I am getting my NSData
- (void)webRequestReceivedData:(NSData *)data {
if(data && [data length]>0) {
NSLog(#"Details are as follows\n%#",
[self startParsingUsingData:data]); //This is the method required which will parse the data
}
}
Hope, now you will be able to parse the data.
I'm parsing an xml file and I can NSLog the parsing, but my problem is that I need to get the image url`s from this "string":
<p>
<img class="alignnone size-thumbnail wp-image-81" title="ex4" src="http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex43-150x150.jpg" alt="" width="150" height="150" />
<img class="alignnone size-thumbnail wp-image-80" title="ex3" src="http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex32-150x150.jpg" alt="" width="150" height="150" />
<img class="alignnone size-thumbnail wp-image-79" title="ex2" src="http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex23-150x150.jpg" alt="" width="150" height="150" />
<img class="alignnone size-thumbnail wp-image-71" title="ex1" src="http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex12-150x150.jpg" alt="" width="150" height="150" />
</p>
Sorry for the plain code :)
what im using to extract the url´s is this code but its not working:
NSRange start = [item.imageGallery rangeOfString:#"http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/"];
NSRange end = [item.imageGallery rangeOfString:#"\" "];
int rangeLength = (int)(end.location - start.location);
NSString *hrefString = [[NSString alloc] initWithString:[item.imageGallery substringWithRange:NSMakeRange(start.location, rangeLength)]];
NSLog(#"image url = %#",hrefString);
Using a regular expression: "src=\"([^\"]+)\""
Here is some example code:
NSString *searchedString = #""
#"<p>"
#"<img class=\"alignnone size-thumbnail wp-image-81\" title=\"ex4\" src=\"http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex43-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" />"
#"<img class=\"alignnone size-thumbnail wp-image-80\" title=\"ex3\" src=\"http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex32-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" />"
#"<img class=\"alignnone size-thumbnail wp-image-79\" title=\"ex2\" src=\"http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex23-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" />"
#"<img class=\"alignnone size-thumbnail wp-image-71\" title=\"ex1\" src=\"http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex12-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" />"
#"</p>";
NSRange rangeOfString = NSMakeRange(0, [searchedString length]);
//NSLog(#"searchedString: %#", searchedString);
NSString *pattern = #"src=\"([^\"]+)\"";
NSError* error = nil;
NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
NSArray *matchs = [regex matchesInString:searchedString options:0 range:rangeOfString];
for (NSTextCheckingResult* match in matchs) {
NSLog(#"url: %#", [searchedString substringWithRange:[match rangeAtIndex:1]]);
}
NSLog Output:
url: http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex43-150x150.jpg
url: http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex32-150x150.jpg
url: http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex23-150x150.jpg
url: http://www.bubblesurprise.com/WPRESS_APP/wp-content/uploads/2012/02/ex12-150x150.jpg
here, I found it for you:
https://stackoverflow.com/a/5999294/1047258
The code from that answer:
NSDataDetector* detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil];
NSArray* matches = [detector matchesInString:source options:0 range:NSMakeRange(0, [source length])];
Then to handle the URL(s):
for (NSTextCheckingResult *match in matches) {
NSURL *url = [match URL];
// do whatever you want with the url
}
How can I get this <firstName> and <lastName>. I have tried a lot but I have messed up.
<list>
<OrderData HASH="1843180441">
<id>26</id><customer>
<CustomerData HASH="882063912">
<id>1</id>
<sex>Male</sex>
<firstName>admin</firstName>
<lastName>admin</lastName>
<companyName>Individual</companyName>
<userName>admin</userName>
<password>21232f297a57a5a743894a0e4a801fc3</password>
<lastLogin>2012-01-26T12:11:38</lastLogin>
<status>A</status>
<created>2011-09-28T07:01:47</created>
<modified>2012-01-26T12:11:38</modified>
<canChangePassword>Y</canChangePassword>
<isDeleted>false</isDeleted>
<abn/>
<abnBranch/>
<storeCredit>50000.0</storeCredit>
<billingAddress>
<list>
<AddressData HASH="768553743">
<id>2</id>
<firstName>admin</firstName>
<lastName>admin</lastName>
<addressLine1>suite: 1307, 9 Yara Street</addressLine1>
<addressLine2>dgdgdf</addressLine2>
<postCode>3000</postCode>
<suburb>dfgdfg</suburb>
<city>sadf</city>
<phone>4456</phone>
<mobile/>
<fax/>
<active>true</active>
<type>C</type>
<email>afzal.bitmascot#gmail.com</email>
<log/>
</AddressData>
</deliveryAddress>
<purchaseDate>2011-10-03T03:23:48</purchaseDate>
</OrderData>
<OrderData HASH="1569451006"></OrderData>
<OrderData HASH="1449383081"></OrderData>
<OrderData HASH="1438157618"></OrderData>
<OrderData HASH="269308788"></OrderData>
</list>
Till now I have done this.
NSLog(#"Enering in the xml file");
NSArray *getNumberOfOrder = [[xmlDocument rootElement] elementsForName:#"OrderData"];
for(GDataXMLElement *e in getNumberOfOrder){
for(int i =0;i<[[e elementsForName:#"customer"]count];i++){
// All orderd customer name
NSString *orderByFirstString = [[[[e elementsForName:#"customer"] objectAtIndex:0] childAtIndex:2] stringValue];
NSString *orderByLastString = [[[[e elementsForName:#"customer"] objectAtIndex:0] childAtIndex:3]stringValue];
orderByString = [NSString stringWithFormat:#"%# %#",orderByFirstString,orderByLastString];
NSLog(#"order By String: %#",orderByString);
}
}
Cordially appreciate for any help or suggestion.
I would try something like this. I would loop through the XML document, and store it in an array.
Notice the NSLog() which will print to the console and will help you see what is going on.
xmlDocument = [[GDataXMLDocument alloc]initWithData:xmlData options:0 error:nil];
NSArray *temp = [xmlDocument.rootElement elementsForName:#"OrderData"];
for(GDataXMLElement *e in temp) {
[outputArray addObject:e];
NSLog(#"%#", e);
}
Then I would loop through the array, and do something like this when I wanted to retrieve a result such as the customer's first name.
for (int i = 0; i < [outputArray count]; i++) {
NSString *firstName = [[[[[[[[outputArray objectAtIndex:i]elementsForName:#"customer"] objectAtIndex:0] elementsForName:#"CustomerData"] objectAtIndex:0] childAtIndex:2]stringValue];
}