File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Trouble adding unique elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Trouble adding unique elements" Watch "Trouble adding unique elements" New topic
Author

Trouble adding unique elements

Dan Grindstaff
Ranch Hand

Joined: Sep 24, 2006
Posts: 138
Hello, I am trying to add a group of elements that must be individually named. I have written the code below:


What I get for xml results is the exact number of fields I need but they are all named "ManufacturerPartNumber". Any help greatly appreciated. Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

You have a Field object. (A GoDataFeed.Fields.Field object to be specific.) You repeatedly call its setName() method. So presuming that setName does something like setting the value of a private "name" variable inside that object, at the end of all your posted code that "name" variable is going to have the value it was last given.

So my guess is that you should create a new Field object for each field, rather than trying to reuse a single Field object.
Dan Grindstaff
Ranch Hand

Joined: Sep 24, 2006
Posts: 138
Thank you very much! Problem resolved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble adding unique elements
 
Similar Threads
server side javascript and Mouseover?
How I can edit 'java.util.Set' DynaValidatorForm form-property
what is synthetic members in java
how to convert a result set into a xml file
Are you man enough to answer this question?