Package org.vietspider.serialize

Examples of org.vietspider.serialize.XML2Bean


   
    String text = document.getTextValue();
    System.out.println(text);
   
   
    XML2Bean xml2Bean = XML2Bean.getInstance();
    Student student2 = xml2Bean.toBean(Student.class, text);
   
    System.out.println("\nstudent 2 name: " +student2.getName());
   
  }
View Full Code Here


  }
 
  private static MetaDocument createRSSDocument(XMLNode node) throws Exception {
    List<XMLNode> children  = node.getChildren();
    if(children == null) return null;
    XML2Bean toBean = XML2Bean.getInstance();
   
    List<XMLNode> itemNodes = null;
    MetaDocument document = null;
   
    for(XMLNode child : children) {
      if(child.isNode(CHANNEL)) {
        if(document == null) document = new MetaDocument();
        document.setChannel(toBean.toBean(RSSChannel.class, child));
        itemNodes = child.getChildren();
        if(itemNodes == null) return document;
        for(XMLNode itemNode : itemNodes) {
          if(!itemNode.isNode(ITEM)) continue;
          RSSItem rssItem = toBean.toBean(RSSItem.class, itemNode);
          parseRSSLink(itemNode, rssItem);
          document.addItem(rssItem);
        }
      } else if(child.isNode(FEED)) {
        if(document == null) document = new MetaDocument();
        document.setChannel(toBean.toBean(FeedItem.class, child));
        itemNodes = child.getChildren();
        if(itemNodes == null) return document;
       
        for(XMLNode itemNode : itemNodes) {
          if(!itemNode.isNode(ENTRY)) continue;
          EntryItem entryItem = toBean.toBean(EntryItem.class, itemNode);
          parseEntryLink(itemNode, entryItem);
          document.addItem(entryItem);
        }
      } else if(child.isNode(ITEM)) {
        if(document == null) document = new MetaDocument();
        RSSItem rssItem = toBean.toBean(RSSItem.class, child);
        parseRSSLink(child, rssItem);
        document.addItem(rssItem);
      }
    }
    return document;
View Full Code Here

  }
 
  private static void parseEntryLink(XMLNode node, IMetaItem item) throws Exception {
    List<XMLNode> children  = node.getChildren();
    if(children == null) return ;
    XML2Bean toBean = XML2Bean.getInstance();
   
    for(XMLNode child : children) {
      if(!child.isNode(LINK)) continue;
      MetaLink metaLink = toBean.toBean(MetaLink.class, child);
      if(metaLink.getHref() == null || metaLink.getHref().trim().isEmpty()) {
        Attributes attributes = AttributeParser.parse(child);
        Attribute attribute = attributes.get(REF);
        if(attribute != null) metaLink.setHref(attribute.getValue());
      }
View Full Code Here

TOP

Related Classes of org.vietspider.serialize.XML2Bean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.