How to get url pictures for further processing? Pars tape (xml sax parser). In the ribbon there is a tag <description> , it contains a picture of the form:

 <div style="text-align: center"><img src="http://gazetaingush.ru/images/stories/2014/161/161-1.gif" border="1" hspace="5" vspace="5" width="450" height="300" /></div><div style="text-align: center"> 

How to pull it out and load it into a layout post?

Update

 item.getChild("link").setEndTextElementListener(new EndTextElementListener(){ public void end(String body) { currentPost.setLink(body); } }); item.getChild("description").setEndTextElementListener(new EndTextElementListener(){ public void end(String body) { currentPost.setDescription(body); } }); 

Here is a piece of code from the parser where we get the <description> itself in the inside of it a picture

Here is the class postItem

 public class PostItem { static SimpleDateFormat FORMATTER = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z", Locale.US); // static SimpleDateFormat OUT_FORMATTER = new SimpleDateFormat("dd.MMM.yyyy HH:mm"); private String title; // Название поста private URL link; // Ссылка на пост на сайте (в формате URL для использования в Java) private String linkText; // Ссылка на пост на сайте (в виде строки текста для вывода) private String description; // Описание поста private Date date; // Дата публикации поста (в формате Date для обработки в программе) /** * Setter для title * @param title */ public void setTitle(String title) { this.title = title.trim(); } /** * Getter для title * @return */ public String getTitle() { return title; } /** * Setter для description * @param description */ public void setDescription(String description) { this.description = description.trim(); } 
  • I don’t know exactly how sax works, but it's obvious that taking the first child from your element and the src attribute from the child. And what is a layout post? - Vladyslav Matviienko

1 answer 1

I would use .//img[1]/@src , but I use another tool.