Using Connect Enterprise Web Services |
|||
| Login and requests > Parse a response with XPath | |||
When you receive an XML response from Connect Enterprise, you need to be able to parse it to extract the XML elements you need.
If you are working in a language such as Java™, with an XML parser (such as Xerces or JDOM) installed, you can parse through an XML response, select values from nodes, and then use those values.
public String scoUrl(String scoId) throws XMLApiException {
try {
Element e = request("sco-info", "sco-id=" + scoId);
if(!(codePath.valueOf(e).equalsIgnoreCase("ok")))
return "";
XPath xpath = XPath.newInstance("//url-path/text()");
String path = ((Text) xpath.selectSingleNode(e)).getText();
e = request("sco-shortcuts", null);
xpath = XPath.newInstance("//domain-name/text()");
String url = ((Text) xpath.selectSingleNode(e)).getText();
return url + "/" + path.substring(1) + "?session=" + breezesession;
} catch (JDOMException jde) {
throw new XMLApiException(PARSE_ERROR, jde);
}
}
You can also use string pattern matching to check for a status code of ok. A successful action always returns this response:
<?xml version="1.0" encoding="utf-8" ?>
<results>
<status code="ok" />
</results>
You can check the response for the pattern ok or code="ok".
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/breeze/6/xml_api/02_logi7.htm