2011-03-28 2 views
0

XML 파서로 GData를 사용하고 있습니다. XPath 쿼리를 사용하여 노드를 검색하려고 시도했습니다. - @ "// GetPlacesAutoCompleteResult". 이지만 getNodesForXPath가 노드를 반환하지 않습니다.IPhone-XPath 쿼리가 내 노드를 가져 오지 않습니다.

그래서 내가 입력 한 쿼리에 무엇이 잘못 되었습니까?

P.S 노드가 있는지 여부를 확인하는 방법 만 찾고 있습니다. 노드 노드가 아닌 노드 노드가 있는지 확인합니다.

여기에 내 .xml 파일 (.ASMX 웹 서비스에 대한 SOAP 쿼리의 결과)입니다.

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
     <GetPlacesAutoCompleteResponse 
     xmlns="http://xxxxxxx.com/xxxxxx/webservice"> 
      <GetPlacesAutoCompleteResult> 
       <xs:schema id="NewDataSet" 
       xmlns="" 
       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
       xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> 
        <xs:element name="NewDataSet" 
           msdata:IsDataSet="true" 
           msdata:UseCurrentLocale="true"> 
         <xs:complexType> 
          <xs:choice minOccurs="0" 
             maxOccurs="unbounded"> 
           <xs:element name="Table"> 
            <xs:complexType> 
             <xs:sequence> 
              <xs:element name="ID" 
                 type="xs:long" 
                 minOccurs="0"/> 
              <xs:element name="FullName" 
                 type="xs:string" 
                 minOccurs="0"/> 
              <xs:element name="PlaceTypeID" 
                 type="xs:int" 
                 minOccurs="0"/> 
             </xs:sequence> 
            </xs:complexType></xs:element> 
          </xs:choice> 
         </xs:complexType></xs:element> 
       </xs:schema> 
       <diffgr:diffgram 
       xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
       xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> 
        <NewDataSet xmlns=""> 
         <Table diffgr:id="Table1" msdata:rowOrder="0"> 
          <ID>47393</ID> 
          <FullName>Yifat</FullName> 
          <PlaceTypeID>10</PlaceTypeID> 
         </Table> 
         <Table diffgr:id="Table2" msdata:rowOrder="1"> 
          <ID>48497</ID> 
          <FullName>Haifa</FullName> 
          <PlaceTypeID>10</PlaceTypeID> 
         </Table> 
         <Table diffgr:id="Table3" msdata:rowOrder="2"> 
          <ID>70827</ID> 
          <FullName 
          >Haifa - Central Bus Rishon</FullName> 
          <PlaceTypeID>120</PlaceTypeID> 
         </Table> 
        </NewDataSet> 
       </diffgr:diffgram> 
      </GetPlacesAutoCompleteResult> 
     </GetPlacesAutoCompleteResponse> 
    </soap:Body> 
</soap:Envelope> 
+0

자주 묻는 질문 중 하나 인 [libxml2 namespace 및 xpath 오류] (http://stackoverflow.com/questions/3135175/libxml2-error-with-namespaces-and-xpath) –

+1

언제든지 액세스 할 수 있습니다. 그것은 다음과 같다 :'[nodes nodesForXPath : @ "// * [name() = 'GetPlacesAutoCompleteResult']"오류 : & 오류; –

답변

2

<GetPlacesAutoCompleteResponse xmlns="http://xxxxxxx.com/xxxxxx/webservice"><GetPlacesAutoCompleteResult> 당신은 그래서 당신은 당신이 네임 스페이스 URI http://xxxxxxx.com/xxxxxx/webservice에 접두사를 바인딩하고 요소 이름을 한정하는 접두사를 사용할 필요가 XPath를 1.0 사용 가정 범위에 기본 네임 스페이스 선언이있다. 예를 들어 접두사가 ws 인 경우 //ws:GetPlacesAutoCompleteResult을 사용합니다.

접두사를 네임 스페이스 URI에 바인딩하는 방법은 사용하는 XPath API에 따라 달라 지므로 GData에 익숙하지 않아 코드 샘플을 사용할 수 없습니다.