문제

아래의 HTML 소스의 양식 값을 어떻게 꺼내서 NSURLConnection에 추가합니까?

<tr>
                            <th><label for="username"><span class="accesskey">N</span>etID:</label></th>
                            <td><input id="username" name="username" class="required" tabindex="1" accesskey="n" type="text" value="" size="32" autocomplete="false"/></td>
                        </tr><tr>
                            <th><label for="password"><span class="accesskey">P</span>assword:</label></th>
                            <td><input id="password" name="password" class="required" tabindex="2" accesskey="p" type="password" value="" size="32"/></td>
                        </tr><tr>
                            <th><label for="authenticationType"><span class="accesskey">A</span>uthentication Type:</label></th>
                            <td>
                               <select id="authenticationType" name="authenticationType">
                                  <option value="Kerberos">Default</option>
                                  <option value="SafeWord">SafeWord</option>
                               </select>
                            </td>
                        </tr><tr>
                            <th></th>
                            <td>
                                <input type="checkbox" id="warn" name="warn" value="true" tabindex="3" />
                                <label for="warn" class="other" accesskey="w"><span class="accesskey">W</span>arn me before logging me into other sites.</label>
                            </td>
                        </tr><tr>
                            <th></th>
                            <td>
                                <input type="hidden" name="_currentStateId" value="" />
                                <input type="hidden" name="_eventId" value="submit" />
                                <input type="submit" accesskey="l" value="LOGIN" tabindex="4" />
                            </td>
                        </tr>
도움이 되었습니까?

해결책 2

나는 사용했다 ElementParser. 감사!

다른 팁

HTML이 유효한 XML이라는 것을 알고 있다면 NSXMLPARSER (또는 기타 XML 패싱 코드)를 통해 모든 것을 실행하고 양식 입력 (예 : 형식 입력) 요소를 감지 할 때마다 약간의 작업을 수행 할 수 있습니다. <input>).

그렇지 않으면, 당신은 자신의 문자열 정기 함수를 작성하는 것이 더 나을 수 있습니다. - 잡으려는 태그의 인스턴스를 찾아, <aind and> 문자 사이에서 모든 텍스트를 뽑고, 공백으로 분할 한 다음 찾을 수 있습니다. 입력 필드의 이름으로 NSURLConnection에 넣을 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top