chris
chris

Reputation: 6823

Flex 4 E4X Filtering By Attributes Has Undefined Variable

I have some xml and I am trying to filter it using e4x. My e4x statement looks like this:

model.config.source.fees..fee.(@min<amount).@amount

My xml looks liks this:

<flex>
  <fees>
    <fee type="credit" min="0.00" max="200.00" amount="6.00"/>
    <fee type="credit" min="200.01" max="370.00" amount="10.00"/>
  </fees>
</flex>

When the e4x statement is run, I get an error message: Error #1065: Variable @min is not defined.

But if I change my statement to model.config.source.fees..fee.@min it will return an xmllist of all the min attribute values, so min is defined, at least in that statement. Why doesnt the original statement work?

Upvotes: 1

Views: 1855

Answers (1)

dchang
dchang

Reputation: 2027

When you use @min<amount it requires that all fee nodes have the min attribute defined. It works for your example xml but maybe you were missing @min in your other test data.

However, if you use this format:

model.config.source.fees..fee.(parseFloat(attribute('min')) < amount).@amount

It will handle all nodes whether the attribute is there or not.

Upvotes: 4

Related Questions