gpt4 book ai didi

javascript - 我如何通过另一个元素从 xml 获取特定值

转载 作者:行者123 更新时间:2023-11-28 04:40:48 24 4
gpt4 key购买 nike

<dataset>
<study recNO="0" seriesRecCount="1">
<patientID>123456</patientID>
<accessionNumber>M120170428105320</accessionNumber>
<patientIDID>35</patientIDID>
<studyUID>2.25.143966910120672170538921915162328371094</studyUID>
<studyUIDID>251</studyUIDID>
</study>
<study recNO="1" seriesRecCount="1">
<patientID>123456</patientID>
<accessionNumber>M120170428105233</accessionNumber>
<patientIDID>35</patientIDID>
<studyUID>2.25.303229748643803883750255516818503774905</studyUID>
<studyUIDID>252</studyUIDID>
</study>
</dataset>

我从 url 查询字符串中获取 accessionNumber。我想通过使用 accessionNumber 获取 studyUID我该如何使用 jQuery?

非常感谢

最佳答案

你可以试试这个:

var xml = $('<dataset><study recNO="0" seriesRecCount="1"><patientID>123456</patientID><accessionNumber>M120170428105320</accessionNumber><patientIDID>35</patientIDID>studyUID>2.25.143966910120672170538921915162328371094</studyUID><studyUIDID>251</studyUIDID></study><study recNO="1" seriesRecCount="1">      <patientID>123456</patientID><accessionNumber>M120170428105233</accessionNumber><patientIDID>35</patientIDID><studyUID>2.25.303229748643803883750255516818503774905</studyUID>      <studyUIDID>252</studyUIDID></study></dataset>');

function getStudyUIDByAccessionNumber (access) {
for (var study of a.find('study')) {
var accessionNumber = study.getElementsByTagName('accessionNumber')[0].innerHTML;
if ( accessionNumber == access) {
return (study.getElementsByTagName('studyUID')[0].innerHTML);
}
}}

getStudyUIDByAccessionNumber('M120170428105233');

关于javascript - 我如何通过另一个元素从 xml 获取特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43798940/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com