我正在使用evernote api与evernote共享一张便条,它是成功的,它将笔记上传到evernote。但是当我从evernote下载笔记到我的应用程序时,它给了我xml formate.my代码中的注释发送便笺是。 在我的按钮单击 {
EDAMNote * note = [[[EDAMNote alloc] init]autorelease];
note.title = @"Appname";
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];
ENML = [NSString stringWithFormat:@"%@%@", ENML, @"</en-note>"];
NSLog(@"%@", ENML);
// Adding the content & resources to the note
[note setContent:ENML];
}
它会将aString
的值正确发送到evernote。
我的Downloding代码是
- (void)viewDidLoad
{
[super viewDidLoad];
// Load the EDAMNote object that has guid we have stored in the object
EDAMNote * note = [(Evernote *)[Evernote sharedInstance] getNote:guid];
// Changing the navigation title & the content block
noteNavigation.topItem.title = [note title];
//adding note to textview
noteContent.text = [note content];
// 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];
}
它正确下载但是它显示了这样的音符
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n<en-note> then our noteeeee in this areaaa>
但我希望textview.how中只有then our noteeeee in this areaaa
来过滤这个吗?
答案 0 :(得分:1)
一种方法是使用NSXMLParser。如果您唯一关心的是一行,那么编写解析器委托就很容易了。所有你需要的是:
一个变量(使用NSMutableString)来保存文本,可能称为noteText
-parser:didStartElement:namespaceURI:qualifiedName:attributes:
方法,以便在您获得noteText
代码时清除<en-note>
-parser:foundCharacters:
方法,可将找到的字符添加到noteText
-parser:didEndElement:namespaceURI:qualifiedName:
方法在获得noteText
代码时使用</en-note>
执行某些操作
答案 1 :(得分:0)
答案 2 :(得分:0)
Apple有两个内置解决方案,用于解析iphone上的XML数据。 XML解析器的目标c实现,称为NSXMLParser,以及基于C的XML解析器实现,称为libXML2。
编辑:
本文介绍如何使用NSXMLParser解析XML
http://www.codeproject.com/Articles/248883/Objective-C-Fundamentals-NSXMLParser