如何将 E4X 属性解释为 Flex 中的日期?
我有如下所示的 XML:
<item>
<itemDate>07/10/2009</itemDate>
</item>
我希望能够将其作为 E4X 对象读取:item.itemDate
并使 itemDate
成为 ActionScript Date
对象而不是字符串。 这可能吗?
I've got XML that looks like this:
<item>
<itemDate>07/10/2009</itemDate>
</item>
I would like to be able to read this in as an E4X object: item.itemDate
and have itemDate
be an ActionScript Date
object instead of a string. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,不。 以 XML 形式出现的所有内容都将是一个字符串 - 甚至是其他原语,如“1”或“false”。
当我必须处理类似的事情时,我会迭代 XML 并创建一个镜像对象(有时甚至是一个无类型对象),并将 String 值转换为其适当的数据类型。
或者,我只是在使用之前将值转换为其适当的数据类型。
If I understand you right, Nope. Everything that comes in as XML will be a string - even other primitives like "1", or "false".
When I have to deal with something like this, I iterate through the XML and create a mirroring Object (sometimes an untyped Object, even) and convert the String values to their appropriate datatypes.
Or, I just convert the value to its appropriate datatype just before use.
只需将值传递给 日期构造函数:
Just pass the value to the Date constructor: