用XML提要中的内容填充flex中的datagrid

用XML提要中的内容填充flex中的datagrid,xml,apache-flex,datagrid,mxml,Xml,Apache Flex,Datagrid,Mxml,我有一个数据网格: <mx:DataGrid id="resultsDataGrid" height="328" width="604" paddingRight="0" editable="false" y="43" horizontalCenter="0"> <mx:columns> <mx:DataGridColumn headerText="Title" dataField=

我有一个数据网格:

    <mx:DataGrid id="resultsDataGrid" 
                 height="328" width="604" paddingRight="0" editable="false" y="43" horizontalCenter="0">
        <mx:columns>
            <mx:DataGridColumn headerText="Title" dataField="title"/>
            <mx:DataGridColumn headerText="Updated" dataField="updated"/>
        </mx:columns>
    </mx:DataGrid>
我只需要将标题和更新的字段实际加载到DataGrid中。
这显然不起作用,所以我来寻求帮助,如果有人有经验,可以告诉我如何正确安排,我将不胜感激。(我认为它与result.entry有关,它一定是result.feed.entry之类的东西,但我尝试了许多组合,但它们都不起作用——除非我没有找到正确的组合。)

奇怪的是,名称空间是导致问题的原因。前缀是为不包含它们的名称空间自动生成的

最简单的解决方案:不要使用名称空间

否则:您需要在此处进行一些研究:

在下面的示例代码中,尝试单击按钮,您将看到发生了什么:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:XML id="atomNamespace">
        <feed xmlns="http://www.w3.org/2005/Atom">
            <title></title>
            <link href="" />
            <link rel="" href="" />
            <updated></updated>
            <author>
                <name></name>
            </author>
            <id></id>
            <entry>
                <title>Title text</title>
                <link href="" />
                <id></id>
                <updated>2010-09-10</updated>
                <published></published>
                <summary></summary>
                <author>
                    <name></name>
                </author>
                <category term="" label="" />
                <category term="" scheme="" />
            </entry>
        </feed>
    </mx:XML>
    <mx:XML id="noNamespace">
        <feed>
            <title></title>
            <link href="" />
            <link rel="" href="" />
            <updated></updated>
            <author>
                <name></name>
            </author>
            <id></id>
            <entry>
                <title>Title text</title>
                <link href="" />
                <id></id>
                <updated>2010-09-10</updated>
                <published></published>
                <summary></summary>
                <author>
                    <name></name>
                </author>
                <category term="" label="" />
                <category term="" scheme="" />
            </entry>
        </feed>
    </mx:XML>
    <mx:DataGrid id="resultList">
        <mx:columns>
            <mx:DataGridColumn headerText="Title" dataField="title" />
            <mx:DataGridColumn headerText="Updated" dataField="updated" />
        </mx:columns>
    </mx:DataGrid>
    <mx:Button label="Atom Namespace" click="resultList.dataProvider = atomNamespace..entry"/>
    <mx:Button label="No Namespace" click="resultList.dataProvider = noNamespace..entry"/>
</mx:Application>

标题文本
2010-09-10
标题文本
2010-09-10

很抱歉花了这么长时间才回复您,但您完全正确。谢谢
        private function searched(event:ResultEvent):void
        {
            var result:XML = XML(event.result);
            //summaryText.text = result.toXMLString();
            //Alert.show(result.children().children().children().toString() + "hey");
            resultsDataGrid.dataProvider = result.entry;
        }
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:XML id="atomNamespace">
        <feed xmlns="http://www.w3.org/2005/Atom">
            <title></title>
            <link href="" />
            <link rel="" href="" />
            <updated></updated>
            <author>
                <name></name>
            </author>
            <id></id>
            <entry>
                <title>Title text</title>
                <link href="" />
                <id></id>
                <updated>2010-09-10</updated>
                <published></published>
                <summary></summary>
                <author>
                    <name></name>
                </author>
                <category term="" label="" />
                <category term="" scheme="" />
            </entry>
        </feed>
    </mx:XML>
    <mx:XML id="noNamespace">
        <feed>
            <title></title>
            <link href="" />
            <link rel="" href="" />
            <updated></updated>
            <author>
                <name></name>
            </author>
            <id></id>
            <entry>
                <title>Title text</title>
                <link href="" />
                <id></id>
                <updated>2010-09-10</updated>
                <published></published>
                <summary></summary>
                <author>
                    <name></name>
                </author>
                <category term="" label="" />
                <category term="" scheme="" />
            </entry>
        </feed>
    </mx:XML>
    <mx:DataGrid id="resultList">
        <mx:columns>
            <mx:DataGridColumn headerText="Title" dataField="title" />
            <mx:DataGridColumn headerText="Updated" dataField="updated" />
        </mx:columns>
    </mx:DataGrid>
    <mx:Button label="Atom Namespace" click="resultList.dataProvider = atomNamespace..entry"/>
    <mx:Button label="No Namespace" click="resultList.dataProvider = noNamespace..entry"/>
</mx:Application>