使用unmarshaller解析XML元素

时间:2013-07-16 08:58:45

标签: xml actionscript-3 jaxb

我有以下XML

<Messages>
<PopUpMessages>
<Message no=”1” type=”game” name=”DONATION”>
Congratulation You won
</Message>
</PopUpMessages>

我正在使用这个http://code.google.com/p/asaxb/,它用于ActionScript,它具有JAXB的基本功能。

问题是我可以获得PopUpMessages,一切都很好,但我无法获得内容
“祝贺你赢了”
,这是在消息内。

定义如下:

    package
    { 
    [XmlRootNode(name = 'Message')]
    public class Message {

        [XmlAttribute(name = "no")]
        public var no:Number;
        [XmlAttribute(name = "type")]
        public var type:String;
        [XmlAttribute(name = "imageSource")]
        public var imageSource:String;
        [XmlAttribute(name = "name")]
        public var name:String;
        [XmlAttribute(name = "k")]
        public var k:String;
    }    
    }

   // The class that I unmarsahall 
    public class GCPResponse {      
        [XmlElement(name="Messages")]
        public var message:Messages;    
    }

    package
    { 
    [XmlRootNode(name = "PopUpMessages")]
    public class PopUpMessages {

        [XmlElement(name="Message")]

        public var  message:Message;     
    }
    }

1 个答案:

答案 0 :(得分:0)

您需要利用@XmlValue注释。