현재 파서로 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으로 배열을 통과하는 것) 큰 멋진 라이브러리를 사용하지 않아도됩니다. 미리 감사드립니다.
업데이트 :
코드 :
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