aspose 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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Trouble adding unique elements" Watch "Trouble adding unique elements" New topic

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

Joined: Oct 14, 2005
Posts: 19331

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.
rocket mass heater kickstarter
subject: Trouble adding unique elements