新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     >>W3CHINA.ORG讨论区<<     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论Java, J2SE, J2ME, J2EE, 以及Eclipse, NetBeans, JBuilder等Java开发环境,还有JSP, JavaServlet, JavaBean, EJB以及struts, hibernate, spring, webwork2, Java 3D, JOGL等相关技术。
    [返回] W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL计算机技术与应用『 Java/Eclipse 』 → [原创]xml提取 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 5535 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [原创]xml提取 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     sfe105 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:5
      积分:66
      门派:XML.ORG.CN
      注册:2010/3/7

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给sfe105发送一个短消息 把sfe105加入好友 查看sfe105的个人资料 搜索sfe105在『 Java/Eclipse 』的所有贴子 引用回复这个贴子 回复这个贴子 查看sfe105的博客楼主
    发贴心情 [原创]xml提取

    对于给定元素名,如何把这个元素下指定的属性名的内容提取出来

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2010/4/15 17:19:00
     
     sfe105 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:5
      积分:66
      门派:XML.ORG.CN
      注册:2010/3/7

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给sfe105发送一个短消息 把sfe105加入好友 查看sfe105的个人资料 搜索sfe105在『 Java/Eclipse 』的所有贴子 引用回复这个贴子 回复这个贴子 查看sfe105的博客2
    发贴心情 
    是不是就是对其子元素的操作
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2010/4/15 17:27:00
     
     mfc42d 帅哥哟,离线,有人找我吗?
      
      
      等级:大三暑假(ITELS考了6.5分!)(版主)
      文章:65
      积分:882
      门派:XML.ORG.CN
      注册:2004/6/13

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给mfc42d发送一个短消息 把mfc42d加入好友 查看mfc42d的个人资料 搜索mfc42d在『 Java/Eclipse 』的所有贴子 引用回复这个贴子 回复这个贴子 查看mfc42d的博客3
    发贴心情 
    5.查找指定名的Element(一个)
    /**
    * Gets the first child element with the given name or returns null if one can't be found.
    * @param parent the parent element of the child element to search for
    * @param childName the name of the child element
    * @param deepSearch - if True then the search will be performed on all levels
    * If False then only Direct childs will be searched
    * @return the first child element with the given name or null if one can't be found.
    */
    public static Element getFirstChildElementNamed(Element parent, String childName, boolean deepSearch)
    {
       if (parent == null)
       {
         throw new NullPointerException("Parent element cannot be null");
       }
       NodeList children = parent.getChildNodes();
       Element child = null;
       for (int i = 0; i < children.getLength() && child == null; i++)
       {
         if (children.item(i).getNodeName().equals(childName))
         {
           child = (Element)children.item(i);
         }
         else if ((deepSearch) && (children.item(i).getNodeType() == Element.ELEMENT_NODE))
         {
           child = getFirstChildElementNamed((Element)children.item(i), childName, deepSearch);
         }
       }
       return child;
    }
    5.查找指定名的Element(一组)
    /**
    * Gets any child elements with the given name or returns null if one can't be found.
    * @param parent the parent element of the child element to search for
    * @param childName the name of the child element
    * @param deepSearch - if True then the search will be performed on all levels
    * If False then only Direct chileds will be searched
    * @return the first child element with the given name or null if one can't be found.
    */
    public static Element[] getAllChildElementNamed(Element parent, String childName, boolean deepSearch)
    {
       if (parent == null)
       {
         throw new NullPointerException("Parent element cannot be null");
       }
       NodeList children = parent.getChildNodes();
       ArrayList child = new ArrayList();
       for (int i = 0; i < children.getLength(); i++)
       {
         if (children.item(i).getNodeName().equals(childName))
         {
           child.add(children.item(i));
         }
         else if ((deepSearch) && (children.item(i).getNodeType() == Element.ELEMENT_NODE))
         {
           Element[] childs = getAllChildElementNamed((Element)children.item(i), childName, deepSearch);
           for (int j=0; j< childs.length; j++)
           {
             child.add(childs[j]);
           }
         }
       }
       return (Element[])child.toArray(new Element[0]);
    }
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2010/5/17 20:09:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Java/Eclipse 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/10 2:28:12

    本主题贴数3,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    63.477ms