I’m using a REST webservice to retrieve some data. As a response I get some long xml or other files. Part of it could look for example like this:
<jfs:jauthRevokeTokenUrl
rdf:resource="https://localhost:9443/jts/jauth-revoke-token" />
<jfs:jauthCheckAuthUrl
rdf:resource="https://localhost:9443/jts/jauth-check-auth" />
<jfs:jauthProxyUrl
rdf:resource="https://localhost:9443/jts/jauth-proxy" />
<jfs:jauthSigninUrl
rdf:resource="https://localhost:9443/jts/jauth-signin" />
If I now want to retrieve the value of rdf:resource of for example the node jfs:jautSigningURL, what Java framework can I use for this? And what if the response is not xml but json? What frameworks can I use then? Or do I have to code this by myself?
If you want to avoid any big framework, you could look at the build in tools of java for parsing XML
Here an example, assuming you have an
XMLstring variableYou could further refine that by including namespace definitions, null checks and maybe simplifying it with an XPath expression, like so
See here Java XML XPATH