Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.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
Flex,XML的后代_Xml_Apache Flex_Actionscript 3 - Fatal编程技术网

Flex,XML的后代

Flex,XML的后代,xml,apache-flex,actionscript-3,Xml,Apache Flex,Actionscript 3,我想获取所有具有以下属性的xml元素(xml后代): <books> <book concept="rr" author="xx"/> <book concept="tt" /> <book concept="yy" /> <book concept="uu" author="xx"/> </books> 我需要对author属性包含 结果应该是: <book concept="r

我想获取所有具有以下属性的xml元素(xml后代):

<books>
    <book concept="rr" author="xx"/>
    <book concept="tt" />
    <book concept="yy" />
    <book concept="uu" author="xx"/>
</books>

我需要对author属性包含 结果应该是:

<book concept="rr" author="xx"/>
<book concept="uu" author="xx"/>

这应该可以回答您的问题:

var booksXML: XML = <books>
    <book concept="rr" author="xx"/>
    <book concept="tt" />
    <book concept="yy" />
    <book concept="uu" author="xx"/>
</books>

for each (var xmlBook: XML in booksXML.children())
{
    if (xmlBook.@author != undefined)
        trace(xmlBook.toXMLString());
}
var-booksXML:XML=
对于每个(booksXML.children()中的var-xmlBook:XML)
{
if(xmlBook@author!=未定义)
trace(xmlBook.toXMLString());
}

这应该可以回答您的问题:

var booksXML: XML = <books>
    <book concept="rr" author="xx"/>
    <book concept="tt" />
    <book concept="yy" />
    <book concept="uu" author="xx"/>
</books>

for each (var xmlBook: XML in booksXML.children())
{
    if (xmlBook.@author != undefined)
        trace(xmlBook.toXMLString());
}
var-booksXML:XML=
对于每个(booksXML.children()中的var-xmlBook:XML)
{
if(xmlBook@author!=未定义)
trace(xmlBook.toXMLString());
}
或使用XML选择器:

var booksXML: XML = <books>
    <book concept="rr" author="xx"/>
    <book concept="tt" />
    <book concept="yy" />
    <book concept="uu" author="xx"/>
</books>

var haveAuthor:XMLList = booksXML.book.(attribute("author").length() > 0);
//booksXML.book.(@author) won't work
var-booksXML:XML=
var haveAuthor:xmlist=booksXML.book。(属性(“author”).length()>0);
//booksXML.book(@author)不起作用
或使用XML选择器:

var booksXML: XML = <books>
    <book concept="rr" author="xx"/>
    <book concept="tt" />
    <book concept="yy" />
    <book concept="uu" author="xx"/>
</books>

var haveAuthor:XMLList = booksXML.book.(attribute("author").length() > 0);
//booksXML.book.(@author) won't work
var-booksXML:XML=
var haveAuthor:xmlist=booksXML.book。(属性(“author”).length()>0);
//booksXML.book(@author)不起作用