I was reading up about DOM and I saw this function DOMCharacterData::appendData
. It appends the string data to the character data. So in layman's terms, what is character data?
views:
35answers:
2
+1
A:
Character data is plain, simple text. Things such as DOMText
and DOMComment
inherit from DOMCharacterData
because they contain text data.
Matti Virkkunen
2010-08-29 10:17:33
I'm going to have to give the best answer to Nick for his example. Nothing personal, but I upvoted your answer as well.
Doug
2010-08-29 10:28:17
+3
A:
It is defined in non layman's terms in the standard here.
But more simply, character data is any text in the HTML, that isn't part of a tag. This is in contrast to tags, attributes etc. It can be just typed as text, or defined with a CDATA section in the html, or a comment etc.
Example html:
<tag attribute="value">This is character data</tag>
<a><![CDATA[This is also all character data]]></a>
<!-- even this comment is character data -->
In the code above "This is all character data" is character data, but the tag surrounding it isn't. The same goes for the CDATA section and the comment. One thing that often surprises people is that whitespace counts as character data.
Nick Fortescue
2010-08-29 10:18:29
For example, is `<a href="stackoverflow.com">SO</a>` character data? or only the SO part?
Doug
2010-08-29 10:20:56
@Doug - well, `<a href="http://stackoverflow.com">SO</a>` has the potential to be character data, but usually isn't. That's what the CDATA bit is for: `<![CDATA[<a href="http://stackoverflow.com">SO</a>]]>`
Matchu
2010-08-31 23:46:41