[jdom-interest] Re: jdom-interest digest, Vol 1 #1298 - 10 msgs

phill_perryman at Mitel.COM phill_perryman at Mitel.COM
Tue Aug 26 00:46:05 PDT 2003


You need to add the attribute and not a text value.

            user.setAttribute(userattr); 

Hi,
I am trying to create the following-
<dataSet>
 <user username="user123" password="xxxxxx1" /> 
</dataSet>
This is my code--
 Element root = new Element("DataSet");
        Document doc = new Document(root);
        Element user = new Element("username");
        Element passwd = new Element("password");
        //Element passwd = new Element("password").setText(str1);
        Attribute userattr = new Attribute(uattr,str);
        Attribute passwdattr = new Attribute(pattr,str1);
        //Element user = new Element("username").setAttribute(str);
        try{ 
            user.setAttribute(str); 
            passwd.setAttribute(str1);
            root.addContent(user);
            root.addContent(passwd);
        } catch(IllegalAddException i) {
            System.out.println(i);
        }
The element attributes will be read from a file. They are not to be 
created.
But this code is not working.
Can anybody tell me how to create the above.

/Phill
IS Dept, Software Engineer.
phill_perryman at mitel.com
http://www.mitel.com
Tel: +44 1291 436023

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20030826/79e577f5/attachment.htm


More information about the jdom-interest mailing list