a file with an &...">

What is the correct way to store a file name in XML?

I use XDocumentto cache a list of files.

<file id="20" size="244318208">a file with an &amp;ersand.txt</file>

In this example, I used XTextand allowed it to automatically exit the characters in the file name, for example, and with&amp;

<file id="20" size="244318208"><![CDATA[a file with an &ersand.txt]]></file>

In this, I used XCDatato use a literal string, not an escaped one, so it appears in XML, as it would in my application.

I wonder if any of them is better than others under any specific conditions, or if it’s just personal taste. Also, if that means anything, file names may or may not contain invalid characters.

+5
source share
4 answers

, " ".

<![CDATA[]]> , (, HTML).

& &amp;, .

+3

XText XCData - LINQ to XML , .

, -CDATA-, , . , - < - , / CDATA.

, XML - , , , . .

+5

. XText. XCData , , , HTML XML.

: . , . , ( ).

+1

.
XML, .

0

All Articles