我正在面临一些情况,我以为事情会很琐碎,一样平常不是那么回事。
我正在对一个网站进行GET调用,返回的结果是HTML,有很多的
RequestSpecification requestSpecification = initRequest()
.basePath("myPathHere");
Response response = requestSpecification.get().then().contentType(ContentType.HTML)
.extract().response();
到目前为止,一切都很好,但后来当我试图转换为XML,它给我空的结果。
我试过
XmlPath htmlPath = new XmlPath(CompatibilityMode.XML, response.getBody().asString());
还
XmlPath htmlPath = new XmlPath(CompatibilityMode.HTML, response.getBody().asString());
我查了一下google上的东西很乱,那应该是很简单的,但为什么它不是?
试试这个。
RequestSpecification requestSpecification = initRequest()
.basePath("myPathHere");
XmlPath htmlPath = requestSpecification
.get()
.xmlPath();
或者这个
RequestSpecification requestSpecification = initRequest()
.basePath("myPathHere");
XmlPath htmlPath = requestSpecification
.get()
.then()
.extract()
.path('');