I am currently creating an xml document from database content. The output of my creation is saved to another database field. When I validate the xml that I have created it is invalid as the data within the xml tags is not valid eg. & symbols, < symbols within the xml tag content.
Should I be encoding the xml content as I create the xml docume开发者_StackOverflownt?
After the data is saved in to the database it is read via batch job written in perl. After the xml content is encoded, can perl decode this content? And if so, how is this achieve?
If you're creating an XML document in C#, you should be using one of the built-in types, like XmlWriter
or XDocument
. That way, the details of escaping characters that need to be escaped is taken care of and you don't have to think about it.
You should do the same on the other side and use some XML parser in Perl.
If you still want to know how is it achieved (you shouldn't need to), then all the characters that can't appear inside a text node are escaped using character entities. For example, <
is escaped as <
.
精彩评论