2012-02-08 5 views
0

私はそれをevernoteに共有することができるメモを持っています。私はそれをsucessfully.butしました。インポートノートと呼ばれるオプションがあります。私problewm textview.but importpageにおける負荷のEvernoteからノートはEvernoteのサーバーにuplodingノートのnote.myコードとXMLギにappersさがiosでxmlから文字列を分離する方法

-(IBAction)sendNoteEvernote:(id)sender{ 
EDAMNote * note = [[[EDAMNote alloc] init]autorelease]; 

    // Setting initial values sent by the user 
    note.title = @"mybibleapp"; 

NSMutableString *str = [[NSMutableString alloc] initWithString:@"NOTES:"]; 

    for (int i = 0; i<[appDelegate.notesArray count]; i++) { 
     NSString * aString = [[NSString alloc] initWithString:[appDelegate.notesArray objectAtIndex:i]] ; 
     NSString * ENML= [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n<en-note>%@",aString]; 
//aString contains the note value 

ENML = [NSString stringWithFormat:@"%@%@", ENML, @"</en-note>"]; 
    NSLog(@"%@", ENML); 

    // Adding the content & resources to the note 
    [note setContent:ENML]; 
@try { 
     [[Evernote sharedInstance] createNote:note]; 
     _acteverbackup.hidden = YES; 
     _actimageeverbackup.hidden =YES; 
    } 
    @catch (EDAMUserException * e) { 
     _acteverbackup.hidden = YES; 
     _actimageeverbackup.hidden =YES; 
     NSString * errorMessage = [NSString stringWithFormat:@"Error saving note: error code %i", [e errorCode]]; 

     proAlertView *alert = [[proAlertView alloc]initWithTitle:@"Evernote" message:errorMessage delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
     [alert setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0] withStrokeColor:[UIColor colorWithHue:0.0 saturation:0.0 brightness:0.0 alpha:1.0]]; 
     [alert show]; 
     [alert release];  
    return; 
    } 

である私はeverrnoteでノートを取得し、正しく これは私のダウンロードまたはインポートコード

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // Load the EDAMNote object that has guid we have stored in the object 
    EDAMNote * note = [(Evernote *)[Evernote sharedInstance] getNote:guid]; 
noteNavigation.topItem.title = [note title]; 

    noteContent.text = [note content]; 
    //noteContent is the textview which display the note 
    // Adding a back button to close the windows 
    UIBarButtonItem* doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(goBack:)]; 

    UINavigationItem *item = [[[UINavigationItem alloc] init] autorelease]; 
    item.leftBarButtonItem = doneButton; 
    item.hidesBackButton = YES; 
    [noteNavigation pushNavigationItem:item animated:NO]; 
    noteNavigation.topItem.title = [note title]; 


} 

noteCo ntentはここで、ノートを表示TextViewには、これは私が唯一mynote is hereこのTextViewの中に必要

<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n<en-note>%@",mynote is here</en-note> 

値取得しています。これをメモと区別するにはどうすればよいですか?

答えて

0

あなたが使用できる非常に素晴らしいNSStringカテゴリがあります。これはプロジェクトMWFeedParserの一部です。具体的には、ファイルNSString + HTMLを探します。

NSString + HTMLカテゴリがXMLデコードをサポートするようになりました。これについてはhereを読むことができます。

…NSString+XMLEntities category depreciated and replaced by NSString+HTML with improved HTML character entity encoding/decoding via Google Toolbox for Mac. 

このカテゴリには、あなたがそれを使用してスマート方法で、NSStringのにXMLを変換することができるはずのNSStringクラスに次のメソッドに

- (NSString *)stringByStrippingTags; 
- (NSString *)stringWithNewLinesAsBRs; 
- (NSString *)stringByRemovingNewLinesAndWhitespace; 
- (NSString *)stringByDecodingHTMLEntities; 
- (NSString *)stringByEncodingHTMLEntities; 

を追加します。

希望します。

+0

haii返信いただきありがとうございます。NSString * summary = [[[noteContent.text.summary stringByStrippingTags] stringByRemovingNewLinesAndWhitespace] stringByDecodingHTMLEntities];を使用することができます。コードは正しいですか? – stackiphone

+0

そこに?plplをxplainできますか? – stackiphone

+0

あなたはそれを試して、それが動作するかどうかを見ることができます。もしここを見れば(https://github.com/renegade78/MWFeedParser/blob/master/Classes/NSString%2BXMLEntities.m)、メソッドstringByDecodingXMLEntities現在はstringByDecodingHTMLEntitiesをすべて使用しています。 – Goles

関連する問題