XML encoding safe?
If you would want to write </mytag>
as the content between <mytag>
and </mytag>
, you have to escape the less-than and greater-than characters, for example. There are several entities defined for escaping:
& -> &
< -> <
> -> >
" -> "
' -> '
What programming language/platform are you using? If you aren't writing the XML all by yourself, there should be ways that you don't have to worry about this!
An XML document that satisfies XML spec is said to be "well-formed," whereas a document that satisfies a schema (such as XHTML) is said to be valid. Since you're rolling your own XML-derived language, you likely want to check well-formedness. If you Google "well-formedness checker," you'd find them online. Any XML parser also could be used to check it.
The basic idea is like @Philipp is saying, you can't use certain characters between the tags (like <
), all begin tags need to match up with end tags, and Unicode characters are properly encoded.
精彩评论