2012-10-24 65 views

回答

1

你不想遍歷的bibliographic-data內容,但只得到一個屬性從中

替換此

$.each(oData['ops:world-patent-data']['exchange-documents']['bibliographic-data'], 
    function(iIndex, mValue) { 
     console.log(mValue['publication-reference']) 
    } 
); 

與:

console.log(oData['ops:world-patent-data']['exchange-documents']['bibliographic-data']['publication-reference']); 

獲取文檔編號:

console.log(oData['ops:world-patent-data']['exchange-documents']['bibliographic-data']['publication-reference']['document-id'][0]['doc-number']); 
+0

謝謝。您的建議有效。如果我替換爲:console.log(oData ['ops:world-patent-data'] ['exchange-documents'] ['exchange-document'] ['bibliographic-data'] ['publication-reference'] [ 'DOC-號碼)']);我收到未定義的消息,我怎麼能達到doc-number屬性? – user1767121

+0

我在答案中更新了它。 – lrsjng

0

你缺少結構中的一個元素,如果我讀這正確:

ops:world-patent-data.exchange-documents.exchange-document.bibliographic-data.publication-reference 

['exchange-document']

所以插入一個小提琴文件將這個,看看這可以幫助你:http://jsfiddle.net/pfJjG/1/

var iam = { 
    "ops:world-patent-data": { 
     "@xmlns": { 
      "ops": "http://ops.epo.org", 
      "$": "http://www.epo.org/exchange", 
      "ccd": "http://www.epo.org/ccd", 
      "xlink": "http://www.w3.org/1999/xlink" 
     }, 
     "ops:meta": { 
      "@name": "elapsed-time", 
      "@value": "31" 
     }, 
     "exchange-documents": { 
      "exchange-document": { 
       "@system": "ops.epo.org", 
       "@family-id": "35636806", 
       "@country": "EP", 
       "@doc-number": "1814517", 
       "@kind": "A1", 
       "bibliographic-data": { 
        "publication-reference": { 
         "document-id": [ 
          { 
          "@document-id-type": "docdb", 
          "country": { 
           "$": "EP" 
          }, 
          "doc-number": { 
           "$": "1814517" 
          }, 
          "kind": { 
           "$": "A1" 
          }, 
          "date": { 
           "$": "20070808" 
          }}, 
         { 
          "@document-id-type": "epodoc", 
          "doc-number": { 
           "$": "EP1814517" 
          }, 
          "date": { 
           "$": "20070808" 
          }} 
         ] 
        }, 
        "classifications-ipcr": { 
         "classification-ipcr": [ 
          { 
          "@sequence": "1", 
          "text": { 
           "$": "A61K 9/ 08   A I" 
          }}, 
         { 
          "@sequence": "2", 
          "text": { 
           "$": "A61K 31/ 19   A I" 
          }}, 
         { 
          "@sequence": "3", 
          "text": { 
           "$": "A61K 31/ 216   A I" 
          }}, 
         { 
          "@sequence": "4", 
          "text": { 
           "$": "A61K 47/ 00   A I" 
          }}] 
        } 
       } 
      } 
     } 
    } 
}; 
$('#me').text(iam["ops:world-patent-data"]["exchange-documents"]["exchange-document"]["bibliographic-data"]["publication-reference"]["document-id"][0]["doc-number"].$); 
+0

謝謝。現在我在控制檯中收到未定義的消息。 – user1767121

相關問題