我有以下XML結構:XPath查詢隨着多個陣列
<xml>
<header>
(Tags goes here)
</header>
<listItem>
<id></id>
...
(Sort of data)
...
<arrayType1>
<id></id>
<parentId></parentId>
<!-- Key: Data to lookup and get the entire structure (listItem) with XPath-->
<key></key>
</arrayType1>
<arrayType2>
<id></id>
<parentId></parentId>
<!-- Key: Data to lookup and get the entire structure (listItem) with XPath-->
<key></key>
</arrayType2>
</listItem>
<listItem>
(Exactly same structure with different data as above)
</listItem>
</xml>
標籤<parentId>
具有<listItem><id>
標籤的相同的數據(不要與各arrayType中的<id>
混淆)。
我需要一個XPath表達式,該表達式返回只有數據的<parentId>
或<listItem><id>
(或者,默認情況下,返回整個arrayTypeX,稍後再處理另一個XSLT轉換)。
我需要在IBM Integration Designer(Websphere ESB)的XSLT Map中進行轉換,但是我對XPath表達式很困惑,但重點僅僅在於構建XPath Expression。
我試圖與此表達式:
/的listItem [arrayType1 [鍵= '值']] /的parentID
但我不知道的XPath支持內部那種語法(陣列數組尋找一個特定的值)。該表達式總是返回列表的第一個ID。
每個項目的基數是:
header: [0..1]
listItem: [0..*]
arrayType1: [0..*]
arrayType2: [0..*]
你能擺脫這個一些輕?
由於
編輯:這是一個例子:
只有具有<xml>
<header>
(Tags goes here)
</header>
<listItem>
<id>1</id>
<arrayType1>
<id>1000</id>
<parentId>1</parentId>
<key>abc</key>
</arrayType1>
<arrayType1>
<id>1500</id>
<parentId>1</parentId>
<key>mno</key>
</arrayType1>
<arrayType2>
<id>2000</id>
<parentId>1</parentId>
<key>def</key>
</arrayType2>
</listItem>
<listItem>
<id>2</id>
<arrayType1>
<id>3000</id>
<parentId>2</parentId>
<key>ghi</key>
</arrayType1>
<arrayType2>
<id>4000</id>
<parentId>2</parentId>
<key>jkl</key>
</arrayType2>
</listItem>
</xml>
的<key>
(例如, 「GHI」)中,i期望獲得<id>
或<parentId>
「2」,與XPath表達式。
請先更正此行:'我需要一個返回或只有數據的XPath表達式,並且還請提供一個我期待的示例輸入/輸出 – sunbabaphu
@sunbabaphu我的錯誤,這是一個錯誤代碼格式。另外我附上了一個我想要得到的例子。 –