<br><font size=3 face="Times New Roman">You need to add the attribute and not a text value.</font>
<br>
<br><font size=3 face="Times New Roman"> user.setAttribute(userattr); </font>
<br>
<br><font size=3 face="Times New Roman">Hi,<br>
I am trying to create the following-<br>
<dataSet><br>
<user username="user123" password="xxxxxx1" /> <br>
</dataSet></font>
<br><font size=3 face="Times New Roman">This is my code--</font>
<br><font size=3 face="Times New Roman"> Element root = new Element("DataSet");<br>
Document doc = new Document(root);<br>
Element user = new Element("username");<br>
Element passwd = new Element("password");<br>
//Element passwd = new Element("password").setText(str1);<br>
Attribute userattr = new Attribute(uattr,str);<br>
Attribute passwdattr = new Attribute(pattr,str1);<br>
//Element user = new Element("username").setAttribute(str);<br>
try{ <br>
user.setAttribute(str); <br>
passwd.setAttribute(str1);<br>
root.addContent(user);<br>
root.addContent(passwd);<br>
} catch(IllegalAddException i) {<br>
System.out.println(i);<br>
}</font>
<br><font size=3 face="Times New Roman">The element attributes will be read from a file. They are not to be created.<br>
But this code is not working.<br>
Can anybody tell me how to create the above.<br>
</font><font size=2 face="sans-serif"><br>
/Phill<br>
IS Dept, Software Engineer.<br>
phill_perryman@mitel.com<br>
http://www.mitel.com<br>
Tel: +44 1291 436023</font>
<p>
<p>