Zack S.
Zack S.

Reputation: 1

All Elements from a XmlBeans XmlObject to String

Is is possible to return all elements of an XMLBeans XMLObject even if they were not set? I have a XmlObject that I generated from an XSD and when I convert the XmlObject to a String I would like to return ALL fields, not just the few that I've set. I tried the following command:

xmlObject.toString();
xmlObject.xmlText();
xmlObject.save(stringWriter); // Then converted the StringWriter to a String

All of the above commands only return the fields I have actually set a value for. If there isn't a command to do this is there an attribute that I can add to the XSD to make the field required? I already have minOccurs="1".

Upvotes: 0

Views: 1900

Answers (1)

DoNuT
DoNuT

Reputation: 487

I guess, you'd have to specify default values for all (mandatory) properties in your schema definition in order to have them implicitly set in the string output of the XmlObject.

Upvotes: 1

Related Questions