-1

Could someone explain what is the difference between setattribute and addContent in Jdom, when I use this for an element, could someone explain the difference?

I have read the API but I was unable to understand that

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
mikroi
  • 3
  • 1
  • Attributes are the things inside the element open tag ``. Content is anything inside the actual element. `Some content`. Read the [javadoc](http://www.jdom.org/docs/apidocs/index.html) for more info. – Paul Samsotha Mar 22 '22 at 15:55
  • Thank you but when i make for example elem.setAttribute(attr,value) woulld that be automatically ? – mikroi Mar 22 '22 at 15:59

1 Answers1

0

setAttribute sets an attribute for the given element.

enter image description here

Attribute is an XML attribute, so, if you have

<elem></elem>

and you call setAttribute, specifying that attr should have the value of val, then it will convert the above to

<elem attr="val"></elem>

addContent appends all children in the given collection to the end of the content list.

enter image description here

So, if you specify your children, then they will be added between the > and the < sign of the element, like

<elem>...</elem>

where ... represents whatever content you have defined.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175