SimpleXML : Add attributes to primitives

164 views Asked by At

I need to parse something like this

<o:address>My address</o:address>

that seems easy, but this element could come as follows

<o:address p:nil="true" />

How can I add a non-required attribute to a primitive, or in this case to a String object?

If there is no way, any suggestions of how could I handle this parsing?

I have no access to the model, I just receive the XML

1

There are 1 answers

0
ollo On

You can set required = false in your annotations. To set an attribute optional, use

@Attribute(name = "nil", required = false)