谁能帮我从.XML中获取价值

问题描述 投票:0回答:1

我将代码保存在selenium-java中,我需要在MS Edge浏览器中打开的.XML中的Identifiers(第二行,而不是第四行)的值。

我的XML:

<Application Type="ABCD">
<Identifier>18753</Identifier>
<SalesChannel SalesChannelType="PQRS" SalesChannelSegment="XYZ">
<Identifier>AB1234</Identifier>

Can anyone help me with the code to get a values(18753) which is between Identifier 2nd line.
Note: I've a code which is working fine for chrome & FF, but bot able to work for MSedge:

Assert.assertTrue(driver.getPageSource().contains("Identifier"));   
String xml =  driver.getPageSource();
String appID = xml.split("<Identifier>")[0].split("</Identifier>")[1];
javascript xml-parsing microsoft-edge browser-automation selenium-edgedriver
1个回答
0
投票

我认为您的split函数存在错误。正确的代码应如下所示:

String appID = xml.split("</Identifier>")[0].split("<Identifier>")[1];
© www.soinside.com 2019 - 2024. All rights reserved.