views:

126

answers:

2

There are dashes in attributes of an xml, and I don't know how to filter them: Here you can see a simple example of the xml:

<posts>
 <post>
     <photo-url max-width="1280">http://blabla.tumblr.com/photo/98&lt;/photo-url&gt;
 </post>
</posts>

Because also the photo-url-tag has a dash, I needed to parse it with …child("photo-url"). This worked fine, but if I want to filter these tags(photo-url), in order to receive all photo-url's with the same attribute: "max-widht='1280'", I couldn't manage to do so. I tried this approach:

var photoUrl:XMLList = xml.posts.post.child("photo-url").(@max-width==1280);

I get this error:

ReferenceError: Error #1065: Variable @max is not defined.

Thx

A: 

Just like you fixed the "photo-url" with the child() function, you should also fix the max-width attribute by using .attribute("max-width").

So your line would look like this:

var photoUrl:XMLList = xml.posts.post.child("photo-url").(attribute("max-width")==1280);
frankhermes
A: 

I don't think you can do it directly. instead of try using for..each..in.

var photoUrls:XMLList = xml.posts.post.child("photo-url");
for each (var child in photoUrls) {
  if (child.attribute("max_width") == "1280");
    trace(child);
}
.

bhups