I’m new to Actionscript.
I’m developing a flex mobile project using the wikipedia api which returns an xml with namespace like this.
<SearchSuggestion version="2.0" xmlns="http://opensearch.org/searchsuggest2">
<Query xml:space="preserve">xml</Query>
<Section>
<Item>
<Text xml:space="preserve">XML</Text>
<Description xml:space="preserve">Extensible Markup Language (XML) is a set of rules for encoding documents in machine-readable form. </Description>
<Url xml:space="preserve">http://en.wikipedia.org/wiki/XML</Url>
</Item>
</Section>
</SearchSuggestion>
But it cannot be recognized as an xml.I’ve tried several ways to deal with the namespace
like
private function removeNamespace(xml:XML):XML
{
var rawXMLString:String=xml.toXMLString();
var xmlnsPattern:RegExp=new RegExp("xmlns=[^\"]*\"[^\"]*\"","gi");
var clean:String=rawXMLString.replace(xmlnsPattern,"");
return new XML(clean);
}
protected function request_resultHandler(event:ResultEvent):void
{
trace(event.result.toString());
responseXML=removeNamespace(new XML(event.result));
resultlist=responseXML.Section;
trace(responseXML.toString());
}
<s:List includeIn="normal" left="0" right="0" top="0" bottom="0" dataProvider=" {resultlist.Item}" labelField="Text"></s:List>
Is there any possible way to deal with this problem and simply convert it into a valid xml and successfully shown in a list.
Have you look on how to deal with namespaces?