-3

I am using a XMLParser Library. I have a xmlDoc and I don't know how can handle some tag values. For example:

<item>
<title>.....</title>
<description>....</description>
</item>

If I have like above xml works fine. But when I want to parse like below xml I cant do it.

<item>
 <enclosure type="image/jpeg" url="https://www....."/>
 <link rel="alternate" type="text/html" href="https://www"/>
</item>

Library url: AEXML

I can retrieve like this:

if let items = xmlDoc.root["item"].all{
for item in items{
print(item["title"].string)
}
}

But I dont know how can get enclosure. Anyone can help me?

Mayday
  • 187
  • 2
  • 8

1 Answers1

1

Simply apply the example to your XML:

for item in items{
    if let enclosure = item["enclosure"] {
        if let url = enclosure.attributes["url"] {
        }
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579