请问我用setAttribute()函数添加属性为什么

winagain 2003-04-07 10:48:05
请问我用setAttribute()函数添加属性为什么
属性会自动按照关键字排序
如何可以不让它排序
我要达到的目的是
先加的属性就在前面
后加的属性就在后面
求教
...全文
866 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gaoxin900 2003-05-30
  • 打赏
  • 举报
回复
建议你用 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";
}
}
wyqiang 2003-05-01
  • 打赏
  • 举报
回复
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.
winagain 2003-04-30
  • 打赏
  • 举报
回复
什么意思
能说的详细点吗
我忘了说明我是用dom解析
wyqiang 2003-04-27
  • 打赏
  • 举报
回复
关于stl
编程
他有自己的函数
public void setAttribute(int index,
String uri,
String localName,
String qName,
String type,
String value
DavidBone 2003-04-20
  • 打赏
  • 举报
回复
ding
AprilChen 2003-04-18
  • 打赏
  • 举报
回复
属性是不分先后的!
winagain 2003-04-08
  • 打赏
  • 举报
回复
请多多指教

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧