当我请求服务器时,我得到了以下xml响应。任何人都可以帮助我如何使用jquery解析这些数据。我只想要选择的节点数据进行解析(student_name,batch_name,admission_date)。
<?xml version="1.0" encoding="UTF-8"?>
<student_detail>
<student>
<student_name>sunil </student_name>
<batch_name>abc</batch_name>
<admission_date>56-2000</admission_date>
<blood_group></blood_group>
<gender>M</gender>
<nationality>India (भारत)</nationality>
<city></city>
<state></state>
<country>India (भारत)</country>
/student_additional_details>
</student>
</student_detail>
答案 0 :(得分:0)
使用parseXML
,您可以阅读自己的价值。
var xml = "<student_detail><student><student_name>sunil </student_name><batch_name>abc</batch_name><admission_date>56-2000</admission_date><blood_group></blood_group><gender>M</gender><nationality>India (भारत)</nationality><city></city><state></state><country>India (भारत)</country>/student_additional_details></student></student_detail>";
xmlDoc = $.parseXML(xml),
$xml = $(xmlDoc),
$student_name = $xml.find("student_name");
$("#someElement").append($student_name.text());
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="someElement"></span>
&#13;