Maybe try var results:XMLList = books.book.(@[“book-id”] == id);

 

Haven’t tested this myself.

 

You need quotes when you’re referring to a property that has a hyphen.

 

Matt

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of quinnwong74
Sent: Monday, July 31, 2006 4:09 PM
To: [email protected]
Subject: [flexcoders] How do I match against an XML attribute that has a hyphen in its name?

 

How do I match against an attribute that has a hyphen in its name?
For example, suppose I have the following actionscript:

private var books:XML;
public function XMLListExample() {
books =
<books>
<book book-id="1" name="Design Patterns" />
<book book-id="1" name="The Pragmatic Programmer" />
<book book-id="1" name="Test Driven Development" />
<book book-id="4" name="Refactoring to Patterns" />
<book book-id="5" name="The Cathedral & the Bazaar" />
<book book-id="6" name="Unit Test Frameworks" />
</books>;

showBooksById("1");
}

private function showBooksById(id:String):void {
var results:XMLList = books.book.(@book-id == id);
showList(results);
}

private function showList(list:XMLList):void {
var item:XML;
for each(item in list) {
trace("item: " + item.toXMLString());
}
}

And I want to match on the node that has a book-id of 1. The
following does not work:

var results:XMLList = books.book.(@book-id == id);

This results in a "ReferenceError: Error #1065: Variable @book is not
defined." and thinks this is a subtraction operation.

Also, using brackets doesn't work as well:

var results:XMLList = books.book.(["@book-id"] == id);

Thanks in advance!

- Quinn

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to