关于stl
编程
他有自己的函数
public void setAttribute(int index,
                         String uri,
                         String localName,
                         String qName,
                         String type,
                         String value

解决方案 »

  1.   

    什么意思
    能说的详细点吗
    我忘了说明我是用dom解析
      

  2.   

    setAttribute
    public void setAttribute(int index,
                             String uri,
                             String localName,
                             String qName,
                             String type,
                             String value)Set an attribute in the list. 
    For the sake of speed, this method does no checking for name conflicts or well-formedness: such checks are the responsibility of the application.
    Parameters:
    index - The index of the attribute (zero-based).
    uri - The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
    localName - The local name, or the empty string if Namespace processing is not being performed.
    qName - The qualified name, or the empty string if qualified names are not available.
    type - The attribute type as a string.
    value - The attribute value. 
    Throws: 
    ArrayIndexOutOfBoundsException - When the supplied index does not point to an attribute in the list.
      

  3.   

    建议你用 ArrayList ,给你个例子看看   protected String getReaderDetails()
       {
          try
          {
           Element RequesterDetailsRoot = new Element("Request");
           Attribute attribute = new Attribute("PROVIDERID","1");
           ArrayList detailAttribute = new ArrayList();
           detailAttribute.add(attribute);
          
           RequesterDetailsRoot.setAttributes(detailAttribute);
           RequesterDetailsRoot.addContent(new Element("CLIENTID").setText("1234"));
           RequesterDetailsRoot.addContent(new Element("CLIENTNAME").setText("myname"));     
           RequesterDetailsRoot.addContent(new Element("FILEID").setText("1"));
           RequesterDetailsRoot.addContent(new Element("FILETITLE").setText("Thinking in Web service"));
          
           Document requesterDetails = new Document(RequesterDetailsRoot);
           XMLOutputter outputter = new XMLOutputter(" ",true);
           return outputter.outputString(requesterDetails);
          }
          catch(Exception e)
          {
           e.printStackTrace(System.out);
           return "Error";
          }
        }