1
votes

I'm trying to read an XML from kuler, but I can't retrieve the values from several tags, and I don't know why.

Particularly this one:

<enclosure xmlns="http://www.solitude.dk/syndication/enclosures/">
  <title>yellow</title> 
- <link length="1" type="image/png">
  <url>http://kuler-api.adobe.com/kuler/themeImages/theme_990712.png</url> 
  </link>
  </enclosure>

For that I have tried

trace(XMLvar.channel.item.enclosure);
trace(XMLvar.channel.item.enclosure[0]);
trace(XMLvar.channel.item.enclosure.text());
trace(XMLvar.channel.item..enclosure);
trace(XMLvar.channel..item..enclosure);

Among others.

I can assure you the route is fine. I can read other values on the same level. I'm checking in Internet Explorer XML 'editor' that they are on the same level. I have checked many times, that is not the problem.

And this is the other one <kuler:themeTitle>:

  <kuler:themeItem>
  <kuler:themeID>990712</kuler:themeID> 
  <kuler:themeTitle>yellow</kuler:themeTitle> 

[...]

I get an error because of the colon when I try to read the value.

(1084: Syntax error: expecting rightparen before colon)

I'm getting quite frustrated now. There is no documentation about this in adobe.livedocs and tutorials on XML like those of kirupa don't say anything about things like these.

2
which tag are you trying to get? - chchrist
For the namespacing, have you read up on namespace node access? - John Giotta
Hi, how are you. @chchrist2: I'm trying to retrieve the info that is enclosed within the <enclosure> tag in the first case. In the 2nd, I want to retrive several values enclosed in tags which have the following format: <kuler:x>, and I get an error because of the colon. - JamesLight
@John Giotta. Hi. I'm reading something about it now... mmm... - JamesLight

2 Answers

0
votes

You could simply grab all descendants matching a given name:

for each (var enclosure:XML in myXML.descendants('enclosure')) {
    var title:String = enclosure.child("title").text();
    ...    
}

Hope that helps a bit. XML gets confusing at times.

0
votes

I've been able through the implementation of namespaces characteristics detailed in the Adobe documentantion to read value of the nodes with the namespace kuler.

here is docs from adobe on namespaces and xml

I can't read the contents of the 'enclosure' node yet, though. :(