<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <wd:Get_Time_Off_Plan_Balances_Response wd:version="v34.0" xmlns:wd="urn:com.workday/bsvc"> <wd:Request_Criteria> <wd:Employee_Reference wd:Descriptor="Sheila Xu (徐舒莘)"> <wd:ID wd:type="WID">6f141c57519e4e14a2b7d1650ac39367</wd:ID> <wd:ID wd:type="Employee_ID">21160</wd:ID> </wd:Employee_Reference> </wd:Request_Criteria> </wd:Get_Time_Off_Plan_Balances_Response> </env:Body></env:Envelope>要读取的属性wd:Descriptor。我试过了/env:Envelope/env:Body/wd:Get_Time_Off_Plan_Balances_Response/wd:Request_Criteria/wd:Employee_Reference/@wd:Descriptor 但它是空的。我如何访问它?我在网上用xpath测试器试了一下,它给了我Attribute='wd:Descriptor=Sheila Xu (徐舒莘)'
2 回答
凤凰求蛊
TA贡献1825条经验 获得超4个赞
显然在浏览器中你可以做类似的事情
const myXmlText = "...your xml string...";
const myXmlParser = new DomParser();
const myXmlDoc = myXmlParser.parseFromString(myXmlText, 'text/xml');
const myDescriptorElement = myXmlDoc.getElementsByTagName('wd:Employee_Reference')[0];
// Now you have a reference to the tag
const myDesiredValue = myDescriptorElement.getAttribute('wd:Descriptor');
这就是我在看的东西,你可能可以玩弄这个来获得你的价值观:
https://www.w3schools.com/xml/xml_parser.asp
¯\_(ツ)_/¯
狐的传说
TA贡献1804条经验 获得超3个赞
要访问Employee_ID
,您可以使用以下 xpath 表达式:
/env:Envelope/env:Body/wd:Get_Time_Off_Plan_Balances_Response/wd:Request_Criteria/wd:Employee_Reference/wd:ID[@wd:type="Employee_ID"]/text()
添加回答
举报
0/150
提交
取消