I want to read Dbx file In my App from The Following site.
http://www.weather.gov/geodata/catalog/wsom/data/bp03my11.dbx
How i can do This?
Any suggestion or any Sample Source Code
since the format of the "dbx" file is something similiar to the CSV (Comma seperated values)
you can find the code that parses the CSV and put the pipe sign ("|") as your seperator
The following link is the sample about the flow of line-break seperated value
http://www.iphonedevsdk.com/forum/iphone-sdk-game-development/13753-tutorial-quiz-game.html#post64855
your attempt is seprating the line-break first and second seprating the | and populate it into NSArray / NSMutableArray / NSDictionary
For the url , you can access it :
NSError* error;
NSString* text = [NSString stringWithContentsOfURL:TheUrl encoding:NSASCIIStringEncoding error:&error];
Refer to : What is the "stringWithContentsOfURL" replacement for objective C?
or use ASIHTTPRequest to ease the steps
http://allseeing-i.com/ASIHTTPRequest/
Related
Let's say I have the following string:
NSString * str = "<a href="http://www.google.com"style="">
</br>
Come onhello world"
How can I parse out the value of the anchor tag--"Come on"?
Should I use HTMLNode.h and HTMLParser.h? Examples would be appreciated.
If it is static, then you can use string manipulation to take out the substring out of the tag
OR
If it is dynamic and html/xml code keeps changing then you can use NSXMLParser. Keep in mind that NSXMLParser should more preferably used only when data is in XML format.
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
Hope this helps.
I would like to use cCSVParse http://michael.stapelberg.de/cCSVParse
in my project. I receive csv data from internet and want to parse it and save to core data. cCSVParse seems to be appropriate class of it. But it can only read csv data from file. When I receive data from internet, I wouldn't like to save it to file. Is there any way to use it for parsing data from NSData or NSString?
One approach is to surround the CSV data (one row at a time) with [] chars and parse it with a JSON parser. (But note that this only works if the non-numeric data items are enclosed in quotes.)
Or you can simply use
NSArray* items = [csvRow componentsSeparatedByString:#","];
if the data items aren't enclosed in quotes.
I currently have an NSString which can take in a message body similar to a tweet.
E.g.
NSString *sampleText = "This text contains the link http://www.google.com"
I need to write a function that can take in this text, detect that a url exists in the string, and be able to replace the url with a placeholder text.
E.g. after the function is used, the text should equal:
sampleText = "This contains contains a LINK"
Can someone please tell me how I can do this? Do I need to use RegEx?
iOS 4 has [NSRegularExpression replaceMatchesInString:options:range:withTemplate:] which looks like a good bet. (It expects an NSMutableString.)
i have an online xml file filled with items.
At startup i check my internet connection, if so, i parse the xml and compare the item objects to those in my sqlite database. One of the item values is 'lastupdated', whichs is a php generated string.
if the lastupdated value from the xml item is different from the value of the one in the database, the item needs to be updated into the database.
I seem to have parsing errors: as the lastupdated value in my database has 10 characters, and the one in my xml file seems to have 11.. When I output both i get the following:
2010-03-26 15:15:07.771 bbc_v1[97647:207] 1269429166
2010-03-26 15:15:07.771 bbc_v1[97647:207]
1269429166
2010-03-26 15:15:07.771 bbc_v1[97647:207] lenght xml item value: 11
2010-03-26 15:15:07.771 bbc_v1[97647:207] length db value: 10
it seems i'm having parsing problems with whitespace and enter/return stuff? How should I clean the xml value?
Try the -stringByTrimmingCharactersInSet function:
NSString* cleanString = [dirtyString stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
What about running strip or trim on the string. This normally eliminates whitespaces.
I'm using libxml2 for SOAP-Actions in an iPhone App.
The big problem is that i want send an SQL-Statement with
NSString *query = #"SELECT test FROM database WHERE test = \"string\""
But libxml2 converts the qotes " into "
Any ideas how to prevent this?
Quotations within the texual data of XML are supposed to be converted to ", per the XML specification. The receiver is responsible for converting " back to quotations when extracting the text from the XML.