1

e4xオブジェクトを作成したい。動的に属性を追加し続け、後で値を追加したいと思います。例 var node = <node />; //コード1)「ノード」に属性を追加2)「ノード」に値を追加

また、Flex3の場合はそのような例を見つけましたが、Javascriptの場合は見つかりませんでした。それ以上のドキュメントもいただければ幸いです

4

1 に答える 1

0

属性または値を追加する場合

var node = <node/>
node.@id = 123
node.toXMLString()
//returns
//<node id="123"/>

動的に名前が付けられた属性を追加する場合は、角括弧を使用します

node.@["prioritory"] = "high"
//returns
//<node id="123" prioritory="high"/>

子要素を追加する場合も同じように機能します

node.description = "Warning"
node.toXMLString()
//<node id="123" prioritory="high">
//  <description>Warning</description>
//</node>

node["location"] = "R23"
node.toXMLString()
//<node id="123" prioritory="high">
//  <description>Warning</description>
//  <location>R23</location>
//</node>

e4x http://wso2.org/project/mashup/0.2/docs/e4xquickstart.htmlをリフレッシュしようとすると、このリンクが役立ちます。

于 2013-05-04T22:21:55.320 に答える