I am new to XML and XML attributes. I have read in some XML documentation that XML can be represented in 2 ways:
Method-1
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
&开发者_开发技巧lt;CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>8.90</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>
Method - 2
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD TITLE="Empire Burlesque" ARTIST="Bob Dylan" COUNTRY="USA" COMPANY="Columbia" PRICE="10.90" YEAR="1985"/>
<CD TITLE="Hide your heart" ARTIST="Bonnie Tyler" COUNTRY="UK" COMPANY="CBS Records" PRICE="8.90" YEAR="1988"/>
</CATALOG>
But for example when I am using this function to filter where price >=9 and display the data in a grid. When using XML Way 1, it works fine, but when I use XML Way 2, the datagrid is empty. Also note that I am using @ Binding at the datafield of each DatagridColumn. My filter function is as such:
private function myFilter(xml:XML):Boolean
{
return Number(xml.PRICE) >= 9;
}
Thanks
In way number 2, the price is an atribute and not a subtag so it should be accessed with the @ symobl.
So for way 2, your filter function should be:
private function myFilter(xml:XML):Boolean
{
return Number(xml.@PRICE) >= 9;
}
Notice the @ before PRICE.
精彩评论