2009-08-03 4 views
0

아래의 html 소스에 대한 양식 값을 추출하여 NSURLConnection에 추가하는 방법은 무엇입니까?웹 페이지의 양식 입력 값을 URLRequest에로드 하시겠습니까?

<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> 
+0

그래서 당신은 HTML 덩어리가있어, 당신이해야 할 일을 혼란 스럽네요. 사용자가 아직 값을 입력하지 않았기 때문에 양식 필드를 읽어야합니까? – Mike

답변

0

당신은 HTML도 유효한 XML 알고 있다면, 당신은 NSXMLParser (또는 다른 XML 파싱 코드)를 통해 모든 일을 실행하고 폼 입력 요소를 감지 할 때마다 (예 : 몇 가지 작업을 수행 <input>).

그렇지 않으면 자신의 문자열 분석 기능을 작성하는 것이 더 나을 것입니다. 잡으려는 태그의 인스턴스를 찾고 < 및 > 자 사이의 모든 텍스트를 가져 와서 공백으로 분리하십시오 , 그리고 NSURLConnection에 넣을 수 있도록 입력 필드의 이름을 찾으십시오.

관련 문제