Tom Hamming
Tom Hamming

Reputation: 10961

Whitespace in XML elements containing only text

Say I have some XML that contains a tag that looks like this:

<tag_name>  Content  </tag_name>

Or this:

<tag_name>
  Content
</tag_name>

Should the whitespace on either end of the text content of the tag be considered part of the content? I don't see this explicitly addressed in the XML spec, but the Text Encoding Initiative seems to say it should be collapsed.

Upvotes: 1

Views: 54

Answers (1)

keshlam
keshlam

Reputation: 8058

XML itself considers the whitespace to be part of the content.

Whether your particular XML-based language does is up to you. If not, then it will be the responsibility of applications which process that language to strip off the whitespace.

Upvotes: 2

Related Questions