I am new to XML and XML attributes. I have read in some XML documentation that XML can be represented in 2 ways:
我是XML和XML属性的新手。我在一些XML文档中读到XML可以用两种方式表示:
Method-1
方法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>
<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
方法 - 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:
但是,例如当我使用此函数来过滤价格> = 9并在网格中显示数据时。使用XML Way 1时,它工作正常,但是当我使用XML Way 2时,datagrid是空的。另请注意,我在每个DatagridColumn的数据字段中使用@Binding。我的过滤功能是这样的:
private function myFilter(xml:XML):Boolean
{
return Number(xml.PRICE) >= 9;
}
Thanks
谢谢
1 个解决方案
#1
1
In way number 2, the price is an atribute and not a subtag so it should be accessed with the @ symobl.
在数字2中,价格是属性而不是子标签,因此应该使用@ symobl访问它。
So for way 2, your filter function should be:
因此,对于方式2,您的过滤器功能应该是:
private function myFilter(xml:XML):Boolean
{
return Number(xml.@PRICE) >= 9;
}
Notice the @ before PRICE.
注意PRICE之前的@。
#1
1
In way number 2, the price is an atribute and not a subtag so it should be accessed with the @ symobl.
在数字2中,价格是属性而不是子标签,因此应该使用@ symobl访问它。
So for way 2, your filter function should be:
因此,对于方式2,您的过滤器功能应该是:
private function myFilter(xml:XML):Boolean
{
return Number(xml.@PRICE) >= 9;
}
Notice the @ before PRICE.
注意PRICE之前的@。