if (sonNode.getAttributes().getNamedItem("us") == null) {

解决方案 »

  1.   

    假如xml为son type="us" con="us">时,我怎样取得con属性的值呢?
      

  2.   

    son type="us" con="us"> ---->  <son type="us" con="us">
      

  3.   

    sonNode.getAttributes().getNamedItem("con")
      

  4.   

    getNamedItem("con")返回的是Node类型,我怎么知道属性con的值呢?可不可以给个具体代码?谢谢了。
      

  5.   

    if(sonNode.getAttributes().getNamedItem("con")!=null){
      Node node = sonNode.getAttributes().getNamedItem("con");
      System.out.println(node.getNodeName()+":"+node.getNodeValue());
    }