My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
XmlElement  
Usage of the XmlElement metadata
Updated Jun 14, 2009 by conrad.w...@gmail.com

Introduction

Used to specify that the associated member is to be marshalled to and from an xml element of the root object node

Details

Used like this for variables

[XmlElement(name="level")]
public var level:int;

or this for getters and setters

private var _level;

[XmlElement(name="level")]
public function get level():int
{
    return _level;
}

public function set level(value:int):void
{
    _level = value;
}
  • The name of the element in the XML and the name of the variable do not need to match
  • For unmarshalling you MUST provide a public setter
Comment by JieGa...@gmail.com, Mar 6, 2010

when the variable is null, then we mashal the object,we will get the xml with the null value of the attribute . We are not expected to see null value in the xml.Therefore,is there any solution for us to realise that?

Comment by project member conrad.w...@gmail.com, Mar 24, 2010

Yes - I will build in a check to make sure that null elements do not get output in the XML - expect a new version soon

Comment by tesujiso...@gmail.com, Oct 6, 2011

How would I define an element that also has an attribute as well as contents? For example:

<property key="id"> 123 </property>

JAXB does support this using @XmlValue?, but it's not clear to me how to define it using this library. BTW, is this project still active?


Sign in to add a comment
Powered by Google Project Hosting