【问题标题】:How can I modify my xml file in actionscript 3如何在 actionscript 3 中修改我的 xml 文件
【发布时间】:2018-10-28 19:34:18
【问题描述】:

我在互联网上有 xml 文件,例如 http://www.w3schools.com/xml/note.xml。我可以在 actionscript 中读取这个 xml 文件。但是我想修改这个 xml,所以我想添加 xml 节点或删除 xml 节点。

例如:

<note>
 <to>Tove</to>
 <from>Jani</from>
 <heading>Reminder</heading>
 <body>Don't forget me this weekend!</body>
</note>

我想添加到我的 xml 笔记的节点中

<example>mynodecontent</example>

后面我要修改,比如我的xml文件上的如下xml

<note>
 <to>Tove</to>
 <from>Jani</from>
 <heading>Reminder</heading>
 <body>Don't forget me this weekend!</body>
 <example>mynodecontent</example>
</note>

有可能吗?

【问题讨论】:

标签: xml actionscript-3 flash xmlhttprequest


【解决方案1】:

试试这个:

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("http://www.w3schools.com/xml/note.xml"));
xmlLoader.addEventListener(Event.COMPLETE, processXML);

var newNode:XML = <example>mynodecontent</example>

function processXML(e:Event):void
{
    var myXML:XML = new XML(e.target.data);

    myXML.insertChildAfter(myXML.body, newNode);

    trace(myXML);
}

如果你想发送修改后的 XML,你就是链接。必须有服务器 PHP 代码或其他。

【讨论】:

  • 我在我的问题上说所以我的 xml 文件在互联网上。例如:w3schools.com/xml/note.xml。我想修改这个xml
  • 稍后我想在链接上的 xml 文件中看到它。新的 xml 必须是我的链接上的 myXML+ newNode
  • 如果您想稍后修改上传到链接。必须有服务器 PHP 或其他。
  • 阅读这篇文章:madssj.com/blog/2008/07/30/…
猜你喜欢
  • 2023-04-02
  • 1970-01-01
  • 2015-06-26
  • 2011-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-09
相关资源
最近更新 更多