How can i get the string in <image>
tags with getValue?<image>https://i2.cnnturk.com/i/cnnturk/75/720x490/5e6f7a9a70380e0cc8f49313</image>
i need https://i2.cnnturk.com/i/cnnturk/75/720x490/5e6f7a9a70380e0cc8f49313
as value.
I'm able to show image, if it's <media:content url=""/>
<media:thumbnail url=""/>
<enclosure url=""/>
and need to show <image>
too.
Also is there any way to format RSS publish date GMT to GMT+3? I need to show as different timezone.
RSS Item:
<item>
<guid isPermaLink="true">5e6f79fe70380e0cc8f49311</guid>
<link>https://www.cnnturk.com/turkiye/istanbul-barosundan-koronaviruse-karsi-avukatlara-acil-mesaj</link>
<title>
<![CDATA[ İstanbul Barosu'ndan koronavirüs'e karşı avukatlara 'acil' mesaj ]]>
</title>
<description>
<![CDATA[ İstanbul Barosu Başkanlığı Koronavirüs nedeniyle "Acil" başlığıyla üye avukatlara mesaj attı. Mesajda duruşmaların 14 Nisan 2020 tarihinden sonra görüleceği, avukatlara bu süreçte dava açılmaması önerildi. ]]>
</description>
<pubDate>Mon, 16 Mar 2020 16:09:49 GMT</pubDate>
<atom:link href="https://www.cnnturk.com/turkiye/istanbul-barosundan-koronaviruse-karsi-avukatlara-acil-mesaj"/>
<image>https://i2.cnnturk.com/i/cnnturk/75/720x490/5e6f7a9a70380e0cc8f49313</image>
</item>
Here is android code:
Need help for
else if (qName.equalsIgnoreCase("image")) { //NEW ADDITION
currentState = State.media;
String attrValue = attributes.getValue("WHAT");
item.setThumburl(attrValue);
_FULL CODE
@Override
public void startElement(final String uri, final String localName,
final String qName, final Attributes attributes)
throws SAXException {
currentState = State.unknown;
tagContent = new StringBuilder();
if (localName.equalsIgnoreCase("item") || localName.equalsIgnoreCase("entry")) {
itemFound = true;
item = new RSSItem();
currentState = State.unknown;
} else if (qName.equalsIgnoreCase("title")) {
currentState = State.title;
} else if (qName.equalsIgnoreCase("description") || qName.equalsIgnoreCase("content:encoded") || qName.equalsIgnoreCase("content")) {
currentState = State.description;
} else if (qName.equalsIgnoreCase("link") || qName.equalsIgnoreCase("origLink")) {
currentState = State.link;
} else if (qName.equalsIgnoreCase("pubdate") || qName.equalsIgnoreCase("published")) {
currentState = State.pubdate;
} else if (qName.equalsIgnoreCase("image")) { //NEW ADDITION
currentState = State.media;
String attrValue = attributes.getValue("WHAT");
item.setThumburl(attrValue);
} else if (qName.equalsIgnoreCase("media:thumbnail")) {
currentState = State.media;
String attrValue = attributes.getValue("url");
item.setThumburl(attrValue);
} else if (qName.equalsIgnoreCase("media:content")){
currentState = State.media;
String attrValue = attributes.getValue("url");
if (attributes.getValue("type") == null || attributes == null){
return;
} else if (attributes.getValue("type").startsWith("image")){
item.setThumburl(attrValue);
} else if (attributes.getValue("type").startsWith("video")){
item.setVideourl(attrValue);
} else if (attributes.getValue("type").startsWith("audio")){
item.setAudiourl(attrValue);
}
} else if (qName.equalsIgnoreCase("enclosure")){
currentState = State.media;
String attrValue = attributes.getValue("url");
if (attributes == null || attributes.getValue("type") == null) {
return;
} else if (attributes.getValue("type").startsWith("image")){
item.setThumburl(attrValue);
} else if (attributes.getValue("type").startsWith("video")){
item.setVideourl(attrValue);
} else if (attributes.getValue("type").startsWith("audio")){
item.setAudiourl(attrValue);
}
}
}
String sete = "<image>https://x.com/a.jpg</image>";
String sete2 = sete.replace("<image>", "");