我有下面的示例XML,並且我正在嘗試編寫一個XPath以提取DtJobInformation關鍵標記中的所有條目。每個請求可以有多個'applicationList'標籤。創建XPath以從XML中提取元素
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:newApp xmlns:ns2="http://abcd.com/">
<userId>7106563</userId>
<EDT>
<applicantList>
<person>
<dateOfBirth>11/04/1984</dateOfBirth>
<firstName>Lawman</firstName>
<gender>Male</gender>
<lastName>Jeans</lastName>
<ssn>562-02-1254</ssn>
</person>
<personId>7106563</personId>
<answerSet>
<answers>
<entry>
<key>monthlyGrossIncome</key>
<value>419</value>
</entry>
<entry>
<key>jobTitle</key>
<value>Flooring</value>
</entry>
<entry>
<key>workOrTraining</key>
<value>Work</value>
</entry>
<entry>
<key>selfEmployment</key>
<value>Yes</value>
</entry>
<entry>
<key>hoursFrequency</key>
<value>Monthly</value>
</entry>
</answers>
<key>DtJobInformation</key>
</answerSet>
<answerSet>
<answers>
<entry>
<key>monthlyGrossIncome</key>
<value>2000</value>
</entry>
<entry>
<key>workOrTraining</key>
<value>Work</value>
</entry>
<entry>
<key>startDate</key>
<value>12/22/2016</value>
</entry>
<entry>
<key>employerName</key>
<value>Aewsome Tire Corp</value>
</entry>
<entry>
<key>selfEmployment</key>
<value>No</value>
</entry>
<entry>
<key>hoursFrequency</key>
<value>Monthly</value>
</entry>
</answers>
<key>DtJobInformation</key>
</answerSet>
<answerSet>
<answers>
<entry>
<key>employerName</key>
<value>Aewsome Tire Corp</value>
</entry>
<entry>
<key>line1</key>
<value>1201 Billiard ST</value>
</entry>
<entry>
<key>city</key>
<value>Peakers</value>
</entry>
<entry>
<key>state</key>
<value>KS</value>
</entry>
<entry>
<key>zipCode</key>
<value>15864</value>
</entry>
</answers>
<key>DtInsuranceFromJob</key>
</answerSet>
</applicantList>
<application>
<applicationId>9202950</applicationId>
</application>
</EDT>
</ns2:newApp>
</soap:Body>
</soap:Envelope>
這是我使用
Select
w.req,
T.*
from mytable w,
xmltable(xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' AS "soap", 'http://abcd.com/' AS "ns2"),
'for $txfr in .
for $txfr_hdr in $txfr/soap:Envelope/soap:Body/ns2:newApp/EDT/applicantList
return
<txfr>
{$txfr_hdr}
</txfr>'
passing xmltype.createxml(w.req)
COLUMNS
personId VARCHAR(30) PATH 'txfr_hdr/personId'
) AS T;
請說明在DtJobInformation鍵標記中的「所有」條目下的含義是什麼?沒有「DtJobInformation鍵標記」。有一個標籤'',其中包含值DtJobInformation。該標籤位於'「等'''元素中。那麼你究竟需要什麼?所有的'answerSet'?所有''?或者是什麼? –
Vadim
對不起,我感到困惑。如果關鍵字是answerSet中的DtJobInformation,我想提取完整的「答案」標記。 – Murali