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
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/