0

对不起,这里的新手。

这是我的代码:

var xmlLoader:URLLoader =  new URLLoader();
xmlLoader.load(new URLRequest("faculty_data.xml"));

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
                                               function xmlLoaded(event:Event):void
{   
var xml:XML = XML(event.target.data);

var result1:String = xml.faculty.(@Wordlookup.match(/Sanchez/)).college.toString();
trace(result1); 
trace output ---> <college>COB</college>
             ---> <college>COE</college>

但我想要这样的输出:COB COE

希望有人可以帮助我...我确实尝试过谷歌...

抱歉,这是我的 XML

     <facultylist> 
    <faculty Wordlookup="Maria Rosario"> 
        <id>1</id> 
        <fullName>Maria Rosario</fullName> 
        <college>CED </college>
        <department>ELMD</department>
    </faculty> 
   <faculty Wordlookup="Liza Sanchez"> 
        <id>2</id>   
        <fullName>Lysa Sanchez</fullName>  
        <college>CED </college>
        <department>Marketing</department>
    </faculty> 
   <faculty Wordlookup="Melany Sanchez"> 
        <id>3</id>     
        <fullName>Melany Sanchez</fullName>
        <college>CLA </college>
        <department>Marketing</department>
    </faculty> 
</facultylist>
4

1 回答 1

0

我不知道您的 XML 是什么样子,但我认为您还过滤了 @Wordlookup == "Sanchez"。

你能试试这个:

var xmlLoader:URLLoader =  new URLLoader();
xmlLoader.load(new URLRequest("faculty_data.xml"));

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{   
    var xml:XML = XML(event.target.data);

    var lstXML:XMLList = xml.faculty.(@Wordlookup.match(/Sanchez/)).college;

    for each(var child:XML in lstXML)
    {
        trace(String(child));
    }
}
于 2013-04-11T08:24:27.183 回答