1

In XML, what is the difference between the attribute of an element and its PCDATA?

For example, say I have

<name>
<first>John</first>
<middle>Fitzgerald Johansen</middle>
<last>Doe</last>
</name>

And using only attributes, I convert it to

<name first=“John”
middle=“Fitzgerald Johansen”
last=“Doe”
/>

Does this invoke any change or is it the same thing expressed in different ways?

Hans
  • 11
  • 1
  • Possible duplicate of [XML attribute vs XML element](https://stackoverflow.com/questions/33746/xml-attribute-vs-xml-element) – IMSoP May 08 '18 at 08:28

1 Answers1

0

That's quite a general question but in essence there is no difference in the information held in either form.

However there are more restrictions on attributes than elements so in general it is probably better to keep the data in elements and only use attributes for metadata, if required.

I can't be more specific as the question is quite broad and any decision would have to be made on the specific requirements.

spodger
  • 1,668
  • 1
  • 12
  • 16