i want to get data between xml tags? how to navigate? and get values..
im using wsdl2objc from google code:http://code.google.com/p/wsdl2objc/
output soapbody follows:
read instruction here: http://code.google.com/p/wsdl2objc/wiki/UsageInstructions
my header file: #import "MService.h"
how to get image source and text value????
please help me....
if([bodyPart isKindOfClass:[types_getFavoriteColorResponseType class]]) {
types_getFavoriteColorResponseType *body = (types_getFavoriteColorResponseType*)bodyPart;
// Now you can extract the color from the response
q.text = body.color;
continue;
}
Ок as far as I understand this is a part which extracts text data from your SOAP response.
BTW you need response to be processed via SAX or DOM? First example in given URL refers to DOM usage, whereas the second to SAX.
More than that I can not tell. Guess you have to read manual or find someone, who worked with this.
Use NSXMLParser, NSXMLParserDelegate for xml parsing, you can get the callbacks with proper values:
parser:didStartElement:namespaceURI:qualifiedName:attributes:
parser:foundCharacters:
parser:didEndElement:namespaceURI:qualifiedName:
Ref: http://developer.apple.com/library/ios/#documentation/cocoa/reference/NSXMLParserDelegate_Protocol/Reference/Reference.html
hey i got the result using sudzc.com
if ([result isKindOfClass:[MSalesPages class]]) {
NSLog(#"Response");
NSMutableArray* pageData = result.PageData;
for(MSalesPage* page in pageData){
NSLog(#"Inside for loop %#", page.Id);
NSMutableArray* images = page.Images;
NSMutableArray* textData = page.TextData;
for(MSalesImg* img in images){
NSLog(#"Image url %#",img.Src);
}
for(MSalesText* text in textData){
NSLog(#"Product Name %#",text.Value);
}
}
}
carefully check with the above xml, u will get the answer :)
Related
I use Zxing library for Barcode, QRCode and Data matrix scanning. scanning process is work fine.
I also get result string from didScanResult delegate method of ZXingWidgetController.
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result {
}
But I have one problem...
how to get type (Text, URL, Address book, Phone Number, Email address etc..) and format (QRCode, Data matrix or Barcode) of result.
please help...
and thanks in advance...
Assuming that currently you are using ZXingWidget right?
Since there is no way to get barcode format in this library. So what i have done is i replaced this library with ZXingObjC library to get barcode type as well as format.
-(void)captureResult:(ZXCapture *)capture result:(ZXResult *)result
{
if (!result) return;
// We got a result. Display information about the result onscreen.
NSString *formatString = [self barcodeFormatToString:result.barcodeFormat];
NSString *display = [NSString stringWithFormat:#"Scanned!\n\nFormat:
%#\n\nContents:\n%#", formatString, result.text];
}
I need to display subscripts and superscripts (only arabic numerals) within a UILabel. The data is taken from an XML file. Here is the snippet of XML file:
<text><![CDATA[Hello World X\u00B2 World Hello]]></text>
Its supposed to display X2 (2 as superscript). When I read the string from the NSXMLParser and display it in the UILabel, it displays it as X\u00B2. Any ideas on how to make it work?
I think you can do something like this, assuming the CDATA contents have been read into an NSString and passed into this function:
-(NSString *)removeUnicodeEscapes:(NSString *)stringWithUnicodeEscapes {
unichar codeValue;
NSMutableString *result = [stringWithUnicodeEscapes mutableCopy];
NSRange unicodeLocation = [result rangeOfString:#"\\u"];
while (unicodeLocation.location != NSNotFound) {
// Get the 4-character hex code
NSRange charCodeRange = NSMakeRange(unicodeLocation.location + 2, 4);
NSString *charCode = [result substringWithRange:charCodeRange];
[[NSScanner scannerWithString:charCode] scanHexInt:&codeValue];
// Convert it to an NSString and replace in original string
NSString *unicodeChar = [NSString stringWithFormat:%C", codeValue];
NSRange replacementRange = NSMakeRange(unicodeLocation.location, 6);
[result replaceCharactersInRange:replacementRange withString:unicodeChar];
unicodeLocation = [result rangeOfString:#"\\u"];
}
return result;
}
I haven't had a chance to try this out, but I think the basic approach would work
\u00B2 is not any sort of XML encoding for characters. Apparently your data source has defined their own encoding scheme (which, frankly, is pretty stupid as XML is capable of encoding these directly, using entities outside of CDATA blocks).
In any case, you'll have to write your own parser that handles \u#### and converts that to the correct character.
I asked the question to my colleague and he gave me a nice and simple workaround. Am describing it here, in case others also get stuck at this.
Firstly goto this link. It has a list of all subscripts and superscripts. For example, in my case, I clicked on "superscript 0". In the following HTML page detailing "superscript 0", goto "Java Data" section and copy the "⁰". You can either place this directly in XML or write a simple regex in obj-c to replace \u00B2 with "⁰". And you will get nice X⁰. Do the same fro anyother superscript or subscript that you might want to display.
I am trying to handle some JSON data. But what I am getting seems to be odd. This is whats returned
JSON: {
drugname = ETOFENAMATE;
"prescribing_notes" = "<b>Muscle pain and inflammation:</b> Apply and massage 5-10cm
strip of gel to affected area.";
rag = {
kidney = A;
lactation = R;
liver = A;
pregnancy = R;
sports = G;
};
So drugname is a NSString
rag is a dictionary.
But what should i be doing with "prescribing notes" ?
I put that object into a NSString but the NSString was then NULL at the end. Its HTML so I will be drawing there text inside a UIWebView when i eventually figure out the correct way to handle/extract it into a NSString.
Thanks,
-Code
You need to check if the JSON object returned is a valid one or not. Use following link to check the validity of JSON String.
JSONLint
I am trying to do search functionality in iPhone. I pass the page number and the string to be searched.. but it is not getting the proper output.
in contentStream I get nothing. I got this code by googling. I don't know what will be there in contentStream object.
-(BOOL)page:(CGPDFPageRef)inPage containsString:(NSString *)inSearchString {
[self setCurrentData:[NSMutableString string]];
CGPDFContentStreamRef contentStream = CGPDFContentStreamCreateWithPage(inPage);
CGPDFScannerRef scanner = CGPDFScannerCreate(contentStream, table, self);
bool ret = CGPDFScannerScan(scanner);
CGPDFScannerRelease(scanner);
CGPDFContentStreamRelease(contentStream);
return ([[currentData uppercaseString]
rangeOfString:[inSearchString uppercaseString]].location != NSNotFound);
}
If there is any other solution then also it is fine.
YOU SHOULD IMPLEMENT THE COMPLETE CODE
http://www.random-ideas.net/posts/42%22
check out the above link
a complete code to do so.
Check out this question and its answers for more information: PDF search on the iPhone
I'm quite new to iphone programming and I want to do the following stuff:
get data from a JSON REST web server
parse the received data using YAJL
Draw a graph with those data using core-plot
So, 1th item is fine, I use ASIHttpRequest which runs as espected
3rd is almost fine (I still have to learn how to tune core-plot).
The problem I have is regarding 2nd item.
I use YAJL as it seems to be the faster parser, so why not give it a try :)
Here is the part of code that gets the data from the server and parse them:
// Get server data
response_data = [request responseData];
// Parse JSON received
self.arrayFromData = [response_data yajl_JSON];
NSLog(#"Array from data: %#", self.arrayFromData);
The parsing works quite well in fact, the NSLog output is something like:
2010-06-14 17:56:35.375 TEST_APP[3733:207] Array from data :
{
data = (
{
val = 1317;
date = "2010-06-10T15:50:01+02:00";
},
{
val = 1573;
date = "2010-06-10T16:20:01+02:00";
},
........
{
val = 840;
date = "2010-06-11T14:50:01+02:00";
},
{
val = 1265;
date = "2010-06-11T15:20:01+02:00";
}
);
from = "2010-06-10T15:50:01+02:00";
to = "2010-06-11T15:20:01+02:00";
max = "2590";
}
According to th yajl-objc explanations http://github.com/gabriel/yajl-objc, the parsing returns a NSArray...
The thing is... I do not know how to get all the values from it as for me it looks more like a NSDictionary than a NSArray...
Could you please help ?
Thanks a lot,
Luc
edit1: it happens that this object is actually a NSCFDictionary (!), I am still not able to get value from it, when I try the objectFromKey method (that should work on a Dictionary, no ?) it fails.
It's returning an NSDictionary. NSCFDictionary is a private subclass and is immaterial to this discussion. So it looks like you'd retrieve stuff like:
NSDictionary * responseDictionary = ...;
NSArray * dataArray = [responseDictionary objectForKey:#"data"];
for (NSDictionary * dataPair in dataArray) {
NSLog(#"val: %#, date: %#", [dataPair objectForKey:#"val"], [dataPair objectForKey:#"date"]);
}