Answer the question
In order to leave comments, you need to log in
Why doesn't the DataProvider want to parse XML?
Good day
From this XML, you need to parse only "users":
<response>
<table>
<name>Какая-то строка</name>
</table>
<links>
<xml>
Какая-то ссылка
</xml>
</links>
<users>
<user>
<id>1</id>
</user>
</users>
</response>
stop();
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.*;
var myXML: XML;
var dp: DataProvider;
var dg: DataGrid;
var urlReq: URLRequest;
var myLoader: URLLoader;
myXML = XML("<response><table><name>Какая-то строка</name></table><links><xml>Какая-то ссылка</xml></links><users><user><id>1</id></user></users></response>");
var ids: DataGridColumn = new DataGridColumn("id");
ids.headerText = "id";
ids.width = 100;
dp = new DataProvider(myXML.users);
dg = new DataGrid();
addChild(dg);
dg.x = 0;
dg.y = 0;
dg.width = 550;
dg.height = 454;
dg.headerHeight = 40;
dg.rowHeight = 30;
dg.columns = [ids];
dg.dataProvider = dp;
dg.rowCount = dp.length;
dg.setSize(550, 400);
<?xml version="1.0" encoding="UTF-8"?>
<response>
<table>
<name>Какая-то строка</name>
</table>
<links>
<xml>
Какая-то ссылка
</xml>
</links>
<user>
<id>1</id>
</user>
</response>
Answer the question
In order to leave comments, you need to log in
You have a lot of discrepancies in your code, first some values then others, so I did everything at random and if something goes wrong, blame yourself. And also I will not comment on the code, if something is not clear, then look in the help.
stop();
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.*;
var myXML: XML;
var dp: DataProvider;
var dg: DataGrid;
var urlReq: URLRequest;
var myLoader: URLLoader;
myXML = <response>
<table>
<name>2</name>
</table>
<links>
<xml>6</xml>
</links>
<users>
<user><id>1</id></user>
<user><id>3</id></user>
</users>
</response>;
var xml:XML = XML(myXML.users);
trace(xml)
var ids: DataGridColumn = new DataGridColumn("id");
ids.headerText = "id";
ids.width = 100;
dp = new DataProvider(xml);
dg = new DataGrid();
addChild(dg);
dg.x = 0;
dg.y = 0;
dg.width = 550;
dg.height = 454;
dg.headerHeight = 40;
dg.rowHeight = 30;
dg.columns = [ids];
dg.dataProvider = dp;
dg.rowCount = dp.length;
dg.setSize(550, 400);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question