Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
as3 xml.replace语法调用_Xml_Actionscript 3_Replace_E4x - Fatal编程技术网

as3 xml.replace语法调用

as3 xml.replace语法调用,xml,actionscript-3,replace,e4x,Xml,Actionscript 3,Replace,E4x,我需要知道如何使用xml.replace 这是我的密码: myXML.replace("WHAT DO PUT HERE?", <p>testing</p>); trace(myXML); 我认为,XML.replace不是一个合适的选择,在这种情况下,它将替换所有设置节点。您可以使用此更具前瞻性的解决方案: var xml:XML = <SETTINGS> <Settin

我需要知道如何使用xml.replace

这是我的密码:

             myXML.replace("WHAT DO PUT HERE?", <p>testing</p>);
             trace(myXML);

我认为,
XML.replace
不是一个合适的选择,在这种情况下,它将替换所有
设置
节点。您可以使用此更具前瞻性的解决方案:

    var xml:XML = <SETTINGS>
          <Settings Title="choice1">Home</Settings>
          <Settings Title="choice2">Options</Settings>
        </SETTINGS>;

    trace("before\n", xml);
    xml.Settings.(@Title == "choice1").* = "Home2";
    xml.Settings.(@Title == "choice2").* = "Options2";

    trace("after\n", xml);
var-xml:xml=
家
选择权
;
跟踪(“在\n之前”,xml);
xml.Settings.(@Title==“choice1”).*=“Home2”;
设置。(@Title==“choice2”).*=“Options2”;
跟踪(“在\n之后”,xml);
输出:

before
 <SETTINGS>
  <Settings Title="choice1">Home</Settings>
  <Settings Title="choice2">Options</Settings>
</SETTINGS>
after
 <SETTINGS>
  <Settings Title="choice1">Home2</Settings>
  <Settings Title="choice2">Options2</Settings>
</SETTINGS>
之前
家
选择权
之后
家庭2
选项2

BAM!没错!您是否建议我更改问题以帮助那些正在搜索相同解决方案的人?或者我应该保持原样,这样他们就可以搜索我的身份并找到你的答案?我还有一个与此相关的问题。我在上面的问题中做了一个编辑。我把它作为一个完整的问题添加到这里。这是个棘手的问题。
    var xml:XML = <SETTINGS>
          <Settings Title="choice1">Home</Settings>
          <Settings Title="choice2">Options</Settings>
        </SETTINGS>;

    trace("before\n", xml);
    xml.Settings.(@Title == "choice1").* = "Home2";
    xml.Settings.(@Title == "choice2").* = "Options2";

    trace("after\n", xml);
before
 <SETTINGS>
  <Settings Title="choice1">Home</Settings>
  <Settings Title="choice2">Options</Settings>
</SETTINGS>
after
 <SETTINGS>
  <Settings Title="choice1">Home2</Settings>
  <Settings Title="choice2">Options2</Settings>
</SETTINGS>