I'm writing a library that creates xml tree from given data.
The problem is that the data contains tags inside nodes.
for example
<node> "this is a very <bold>huge</bold> text" </node>
quotes - just to separate text given to me=)
When I create an xml using libxml and then write it to console (using xmlDumpMEmeory) I get:
<node>this is a very <bold>huge</bold> text</node>
I understand why it's so but have no idea开发者_StackOverflow中文版s how to fix that normally. The only solution I see is to manually replace < and > in my ::ToString() But are there any other symbols (like <,>) that I should replace?
Thx for attention
If you wish to embed special characters such as this in the element contents, they need to be wrapped as CDATA. A conformant XML implementation will always do what you noticed here.
libxml should have some way to write element contents as CDATA that should fix this for you. This looks promising:
Function: xmlTextWriterWriteCDATA
Write an xml CDATA.
精彩评论