2011-08-04 11 views
0

私は<pで開始され、ある.what /p>で終わる文字列を必要とするという点で、IOSのファイルから文字列を構築する

<TEXTFORMAT LEADING='2'><P ALIGN='LEFT'><FONT FACE='Arial' SIZE='10' COLOR='#000000' LETTERSPACING='0' KERNING='0'>Kiran</FONT></P></TEXTFORMAT> <TEXTFORMAT LEADING='2'><P ALIGN='LEFT'><FONT FACE='Arial' SIZE='10' COLOR='#000000' LETTERSPACING='0' KERNING='0'> Ajay</FONT></P></TEXTFORMAT></isText><isValue></isValue><isCorrectAnswer></isCorrectAnswer>

情報以下のものが含まれているファイルを読み込むしようとしています可能な限り最良の方法です。

* *私の考え 文字ずつ1.Readingし、上記

を解析するNSXmlParserを2.using

をチェックする良いものである私を助け、他のあなたの提案を教えてくださいあなたが良いテクニックを持っているなら、このアプローチよりも。

あなたの提案は私にとってより価値です。 ありがとうございます。

+1

の書式がいいだろう: TouchXML installation

、ここではあなたの問題を解決するコードです。 – Perception

+0

あなたの提案をありがとう – ajay

+0

私はそれを変更します.. – ajay

答えて

0

あなたはTouchXMLを使用して試すことができます:

NSMutableArray *res = [[NSMutableArray alloc] init]; 
//xmlInput is your string as NSString 
CXMLDocument *doc = [[[CXMLDocument alloc] initWithData:[xmlInput dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil] autorelease]; 

NSArray *nodes = NULL; 
nodes = [doc nodesForXPath:@"////P" error:nil]; 

for (CXMLElement *node in nodes) { 
    NSMutableDictionary *item = [[NSMutableDictionary alloc] init]; 
    [item setObject:[node XMLString] forKey:@"p"];   
    [res addObject:item]; 
    [item release]; 
} 
NSLog(@"%@", res); 
[res release]; 
関連する問題