Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Visit all attributes for a given element?

Help
Max Rahder
2008-02-25
2013-05-15
  • Max Rahder
    Max Rahder
    2008-02-25

    How do I visit all attributes for a given element? I see that there's a "getAttrValue(String name)" to get the value for a known name, but I want to parse a file where I don't know the attribute names.

    :-) Thanks!

     
    • jimmy zhang
      jimmy zhang
      2008-02-25

      I think that you can just write an XPath for that

      int i=-1;
      ap.selectXPath("@*");
      while ((i=ap.evalXPath())!=1){
         System.out.println("attr name "+vn.toString(i));
         System.out.println("attr val "+vn.toString(i+1));
      }