New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic root tag name #140
Comments
I'm not 100% sure what you mean with "dynamic" but yes, that is possible you have to annotate 2 classes though: @Xml
class Response1 {
@PropertyElement
String foo;
} @Xml
class Response2 {
@PropertyElement
String bar;
} When parsing you just have to tell TikXML to either parse |
What if you don't know what response you're expecting?
Or there are different response types inherited from some "BaseResponse". Just like this case: But on root element. |
Take a look at this unresolved question years ago: |
No, it's not supported and I think error responses in general as return value is not best practice for REST API's (use HTTP Status codes) With that said, reading such xml might work as following (haven't tried it yet, so you have to give it a try on your own): @Xml
class Response {
@Element
Foo foo;
@Element
Error error;
} So you always parse into Writing xml is defenitely not supported as it will produce <response>
<foo>...</foo>
</response> or <response>
<error>...</error>
</response> |
I know at least one xml protocol (by CISCO) which is actually based on different root tags and those are not bound to specific endpoints. So you'll never know what response may come. Will convert the responses manually then. PS: you could change this to "feature request", if anyone cares.. |
You could do some "semi automated parsing" if you know all possible root tags by writing your own |
I was looking for a simple solution on how to proceed when there are different responses.
I could find some info about dynamic element within root, but not the root itself.
Is this not supported by this library?
The text was updated successfully, but these errors were encountered: