List of usage examples for org.jdom2 Element getChild
public Element getChild(final String cname, final Namespace ns)
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
/** * Parses an item element of an RSS document looking for item information. * <p/>/*from w w w . j av a 2 s . c om*/ * It first invokes super.parseItem and then parses and injects the description property if present. * <p/> * * @param rssRoot the root element of the RSS document in case it's needed for context. * @param eItem the item element to parse. * @return the parsed RSSItem bean. */ protected Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("description", getRSSNamespace()); if (e != null) { item.setDescription(parseItemDescription(rssRoot, e)); } Element ce = eItem.getChild("encoded", getContentNamespace()); if (ce != null) { Content content = new Content(); content.setType(Content.HTML); content.setValue(ce.getText()); item.setContent(content); } return item; }
From source file:com.sun.syndication.io.impl.RSS092Parser.java
License:Open Source License
protected WireFeed parseChannel(Element rssRoot) { Channel channel = (Channel) super.parseChannel(rssRoot); Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); Element eCloud = eChannel.getChild("cloud", getRSSNamespace()); if (eCloud != null) { Cloud cloud = new Cloud(); String att = eCloud.getAttributeValue("domain");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { cloud.setDomain(att);//from w w w . j a va 2s . c om } att = eCloud.getAttributeValue("port");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { cloud.setPort(Integer.parseInt(att.trim())); } att = eCloud.getAttributeValue("path");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { cloud.setPath(att); } att = eCloud.getAttributeValue("registerProcedure");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { cloud.setRegisterProcedure(att); } att = eCloud.getAttributeValue("protocol");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { cloud.setProtocol(att); } channel.setCloud(cloud); } return channel; }
From source file:com.sun.syndication.io.impl.RSS092Parser.java
License:Open Source License
protected Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("source", getRSSNamespace()); if (e != null) { Source source = new Source(); String url = e.getAttributeValue("url");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK source.setUrl(url);/*from w w w. j a v a 2s . c o m*/ source.setValue(e.getText()); item.setSource(source); } // 0.92 allows one enclosure occurrence, 0.93 multiple // just saving to write some code. List eEnclosures = eItem.getChildren("enclosure");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (eEnclosures.size() > 0) { List enclosures = new ArrayList(); for (int i = 0; i < eEnclosures.size(); i++) { e = (Element) eEnclosures.get(i); Enclosure enclosure = new Enclosure(); String att = e.getAttributeValue("url");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { enclosure.setUrl(att); } att = e.getAttributeValue("length");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK enclosure.setLength(NumberParser.parseLong(att, 0L)); att = e.getAttributeValue("type");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { enclosure.setType(att); } enclosures.add(enclosure); } item.setEnclosures(enclosures); } List eCats = eItem.getChildren("category");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK item.setCategories(parseCategories(eCats)); return item; }
From source file:com.sun.syndication.io.impl.RSS093Parser.java
License:Open Source License
protected Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("pubDate", getRSSNamespace()); if (e != null) { item.setPubDate(DateParser.parseDate(e.getText())); }/*w w w. jav a 2 s . c o m*/ e = eItem.getChild("expirationDate", getRSSNamespace()); if (e != null) { item.setExpirationDate(DateParser.parseDate(e.getText())); } e = eItem.getChild("description", getRSSNamespace()); if (e != null) { String type = e.getAttributeValue("type"); if (type != null) { item.getDescription().setType(type); } } return item; }
From source file:com.sun.syndication.io.impl.RSS094Generator.java
License:Open Source License
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item, eItem, index); Description description = item.getDescription(); if (description != null && description.getType() != null) { Element eDescription = eItem.getChild("description", getFeedNamespace()); eDescription.setAttribute(new Attribute("type", description.getType())); }/*from ww w.j a v a2 s . c o m*/ eItem.removeChild("expirationDate", getFeedNamespace()); }
From source file:com.sun.syndication.io.impl.RSS094Parser.java
License:Open Source License
protected WireFeed parseChannel(Element rssRoot) { Channel channel = (Channel) super.parseChannel(rssRoot); Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); List eCats = eChannel.getChildren("category", getRSSNamespace()); channel.setCategories(parseCategories(eCats)); Element eTtl = eChannel.getChild("ttl", getRSSNamespace()); if (eTtl != null && eTtl.getText() != null) { Integer ttlValue = null;//from w w w .ja va 2s. c o m try { ttlValue = new Integer(eTtl.getText()); } catch (NumberFormatException nfe) { ; //let it go by } if (ttlValue != null) { channel.setTtl(ttlValue.intValue()); } } return channel; }
From source file:com.sun.syndication.io.impl.RSS094Parser.java
License:Open Source License
public Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); item.setExpirationDate(null);/* ww w . j a v a 2 s. c o m*/ Element e = eItem.getChild("author", getRSSNamespace()); if (e != null) { item.setAuthor(e.getText()); } e = eItem.getChild("guid", getRSSNamespace()); if (e != null) { Guid guid = new Guid(); String att = e.getAttributeValue("isPermaLink");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { guid.setPermaLink(att.equalsIgnoreCase("true")); } guid.setValue(e.getText()); item.setGuid(guid); } e = eItem.getChild("comments", getRSSNamespace()); if (e != null) { item.setComments(e.getText()); } return item; }
From source file:com.sun.syndication.io.impl.RSS10Parser.java
License:Open Source License
/** * Parses an item element of an RSS document looking for item information. * <p/>/*www . j a v a2s .c o m*/ * It first invokes super.parseItem and then parses and injects the description property if present. * <p/> * * @param rssRoot the root element of the RSS document in case it's needed for context. * @param eItem the item element to parse. * @return the parsed RSSItem bean. */ protected Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("description", getRSSNamespace()); if (e != null) { item.setDescription(parseItemDescription(rssRoot, e)); } Element ce = eItem.getChild("encoded", getContentNamespace()); if (ce != null) { Content content = new Content(); content.setType(Content.HTML); content.setValue(ce.getText()); item.setContent(content); } String uri = eItem.getAttributeValue("about", getRDFNamespace()); if (uri != null) { item.setUri(uri); } return item; }
From source file:com.sun.syndication.io.impl.RSS10Parser.java
License:Open Source License
protected WireFeed parseChannel(Element rssRoot) { Channel channel = (Channel) super.parseChannel(rssRoot); Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); String uri = eChannel.getAttributeValue("about", getRDFNamespace()); if (uri != null) { channel.setUri(uri);/*from www. ja v a 2 s. c o m*/ } return channel; }
From source file:com.sun.syndication.io.impl.RSS20Generator.java
License:Open Source License
public void populateItem(Item item, Element eItem, int index) { super.populateItem(item, eItem, index); Element eDescription = eItem.getChild("description", getFeedNamespace()); if (eDescription != null) eDescription.removeAttribute("type"); String author = item.getAuthor(); if (author != null) { eItem.addContent(generateSimpleElement("author", author)); }/*ww w.j av a 2 s . co m*/ String comments = item.getComments(); if (comments != null) { eItem.addContent(generateSimpleElement("comments", comments)); } Guid guid = item.getGuid(); if (guid != null) { Element eGuid = generateSimpleElement("guid", guid.getValue()); if (!guid.isPermaLink()) { eGuid.setAttribute("isPermaLink", "false"); } eItem.addContent(eGuid); } }