0

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>
    <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

0

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Holy Man! I missed that completely..How dumb from my part. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.