0
我目前使用SMXMLDocument作为我的分析器,到目前为止,它解析一些XML文件的功能非常出色。我遇到的唯一问题是,它似乎无法处理同名儿童,至少在我的情况下。但是这个解析器可以将解析的XML作为一个NSArray返回。从NSArray获取XML值
的NSArray的是这样的:
(
"<id>https://spreadsheets.goog\U2026</id>",
"<updated>2013-12-23T17:54:04.814Z</updated>",
"<category term=\"http://schemas.google.com/spreadsheets/2006#cell\" scheme=\"http://schemas.google.com/spreadsheets/2006\"/>",
"<title type=\"text\">A1</title>",
"<content type=\"text\">What?</content>",
"<link rel=\"self\" type=\"application/atom+xml\" href=\"https://spreadsheets.google.com/feeds/cells/some key/od6/private/full/R1C1\"/>",
"<link rel=\"edit\" type=\"application/atom+xml\" href=\"https://spreadsheets.google.com/feeds/cells/some key/18o84x\"/>",
"<cell row=\"1\" col=\"1\" inputValue=\"What?\">What?</cell>",
"<id>A1</id>",
"<status code=\"200\" reason=\"Success\"/>",
"<operation type=\"update\"/>")
所以我的问题是,如何将我得到的值(和属性)从XML?如果有一种方法来标记这个(即通过数组作为一个带有for-in循环的NSString或某个东西),而不必使用一个很棒的大型花式库。提前致谢。
更新:
这里是发生什么事了的NSLog,如果我尝试获取ID与SMXMLDocument:
代码:
SMXMLElement* testEntry = [feed childNamed:@"entry"];
NSLog(@"id: %@", [testEntry valueWithPath:@"id"]);
输出:
id: https://spreadsheets.google.com/feeds/cells/some key/od6/private/full/R1C1
你可以发布你的尝试代码?您链接的SMXMLDocument页面上的示例似乎用'NSString * title = [book valueWithPath:@“title”]回答您的问题; //快速枚举循环中的//子节点值。 –
我添加了代码。请参阅更新。 – iwatakeshi
你也不能用'valueWithPath:'快速枚举。 Xcode会给我一个“可能不会回应”的警告。 – iwatakeshi